|
64 | 64 | }
|
65 | 65 | ],
|
66 | 66 | "source": [
|
67 |
| - "%pip install -q \"gradio>=3.50.2\"\n", |
68 |
| - "%pip install -q \"diffusers>=-1.14.0\" \"openvino>=2023.2.0\" \"transformers>=4.25.1\"" |
| 67 | + "%pip install -q \"gradio>=4.10.0\"\n", |
| 68 | + "%pip install -q torch torchvision --extra-index-url \"https://download.pytorch.org/whl/cpu\"\n", |
| 69 | + "%pip install -q \"diffusers>=-1.14.0\" \"openvino>=2023.2.0\" \"transformers>=4.25.1\" ipywidgets opencv_python" |
69 | 70 | ]
|
70 | 71 | },
|
71 | 72 | {
|
|
1151 | 1152 | "example = {}\n",
|
1152 | 1153 | "ref_dir = 'data/reference'\n",
|
1153 | 1154 | "image_dir = 'data/image'\n",
|
1154 |
| - "ref_list = [os.path.join(ref_dir,file) for file in os.listdir(ref_dir)]\n", |
| 1155 | + "ref_list = [os.path.join(ref_dir,file) for file in os.listdir(ref_dir) if file.endswith(\".jpg\")]\n", |
1155 | 1156 | "ref_list.sort()\n",
|
1156 |
| - "image_list = [os.path.join(image_dir,file) for file in os.listdir(image_dir)]\n", |
| 1157 | + "image_list = [os.path.join(image_dir,file) for file in os.listdir(image_dir) if file.endswith(\".png\")]\n", |
1157 | 1158 | "image_list.sort()\n",
|
1158 | 1159 | "\n",
|
1159 | 1160 | "\n",
|
1160 | 1161 | "image_blocks = gr.Blocks()\n",
|
1161 | 1162 | "with image_blocks as demo:\n",
|
1162 | 1163 | " with gr.Group():\n",
|
1163 |
| - " with gr.Box():\n", |
1164 |
| - " with gr.Row():\n", |
1165 |
| - " with gr.Column():\n", |
1166 |
| - " image = gr.Image(source='upload', tool='sketch', elem_id=\"image_upload\", type=\"pil\", label=\"Source Image\")\n", |
1167 |
| - " reference = gr.Image(source='upload', elem_id=\"image_upload\", type=\"pil\", label=\"Reference Image\")\n", |
1168 |
| - "\n", |
1169 |
| - " with gr.Column():\n", |
1170 |
| - " image_out = gr.Image(label=\"Output\", elem_id=\"output-img\")\n", |
1171 |
| - " steps = gr.Slider(label=\"Steps\", value=15, minimum=2, maximum=75, step=1,interactive=True)\n", |
1172 |
| - "\n", |
1173 |
| - " seed = gr.Slider(0, 10000, label='Seed (0 = random)', value=0, step=1)\n", |
1174 |
| - "\n", |
1175 |
| - " with gr.Row(elem_id=\"prompt-container\"):\n", |
1176 |
| - " btn = gr.Button(\"Paint!\")\n", |
1177 |
| - " \n", |
1178 |
| - " with gr.Row():\n", |
1179 |
| - " with gr.Column():\n", |
1180 |
| - " gr.Examples(image_list, inputs=[image],label=\"Examples - Source Image\",examples_per_page=12)\n", |
1181 |
| - " with gr.Column():\n", |
1182 |
| - " gr.Examples(ref_list, inputs=[reference],label=\"Examples - Reference Image\",examples_per_page=12)\n", |
1183 |
| - " \n", |
1184 |
| - " btn.click(fn=predict, inputs=[image, reference, seed, steps], outputs=[image_out])\n", |
| 1164 | + " with gr.Row():\n", |
| 1165 | + " with gr.Column():\n", |
| 1166 | + " image = gr.ImageEditor(sources=['upload'], type=\"pil\", label=\"Source Image\")\n", |
| 1167 | + " reference = gr.Image(sources=['upload'], type=\"pil\", label=\"Reference Image\")\n", |
| 1168 | + "\n", |
| 1169 | + " with gr.Column():\n", |
| 1170 | + " image_out = gr.Image(label=\"Output\", elem_id=\"output-img\")\n", |
| 1171 | + " steps = gr.Slider(label=\"Steps\", value=15, minimum=2, maximum=75, step=1,interactive=True)\n", |
| 1172 | + "\n", |
| 1173 | + " seed = gr.Slider(0, 10000, label='Seed (0 = random)', value=0, step=1)\n", |
| 1174 | + "\n", |
| 1175 | + " with gr.Row(elem_id=\"prompt-container\"):\n", |
| 1176 | + " btn = gr.Button(\"Paint!\")\n", |
| 1177 | + " \n", |
| 1178 | + " with gr.Row():\n", |
| 1179 | + " with gr.Column():\n", |
| 1180 | + " gr.Examples(image_list, inputs=[image],label=\"Examples - Source Image\",examples_per_page=12)\n", |
| 1181 | + " with gr.Column():\n", |
| 1182 | + " gr.Examples(ref_list, inputs=[reference],label=\"Examples - Reference Image\",examples_per_page=12)\n", |
| 1183 | + " \n", |
| 1184 | + " btn.click(fn=predict, inputs=[image, reference, seed, steps], outputs=[image_out])\n", |
1185 | 1185 | "\n",
|
1186 | 1186 | "# Launching the Gradio app\n",
|
1187 | 1187 | "try:\n",
|
|
0 commit comments