File size: 1,280 Bytes
e3e3bd8
1
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: fake_diffusion\n", "### This demo uses a fake model to showcase iterative output. The Image output will update every time a generator is returned until the final image.\n", "        "]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio numpy "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import numpy as np\n", "import time\n", "\n", "def fake_diffusion(steps):\n", "    rng = np.random.default_rng()\n", "    for i in range(steps):\n", "        time.sleep(1)\n", "        image = rng.random(size=(600, 600, 3))\n", "        yield image\n", "    image = np.ones((1000,1000,3), np.uint8)\n", "    image[:] = [255, 124, 0]\n", "    yield image\n", "\n", "demo = gr.Interface(fake_diffusion,\n", "                    inputs=gr.Slider(1, 10, 3, step=1),\n", "                    outputs=\"image\")\n", "\n", "if __name__ == \"__main__\":\n", "    demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}