Spaces:
Runtime error
Runtime error
add example
Browse files
app.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
| 1 |
import os
|
| 2 |
-
os.system('pip uninstall -y gradio_fake3d')
|
| 3 |
-
os.system('pip install gradio_fake3d-0.0.3-py3-none-any.whl')
|
| 4 |
|
| 5 |
import gradio as gr
|
| 6 |
import re
|
| 7 |
from gradio_fake3d import Fake3D
|
| 8 |
from PIL import Image
|
| 9 |
-
from Rodin import Generator, crop_image
|
| 10 |
from constant import *
|
| 11 |
|
| 12 |
generator = Generator(USER, PASSWORD, TOKEN)
|
|
@@ -61,16 +61,16 @@ options = [
|
|
| 61 |
]
|
| 62 |
|
| 63 |
example = [
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
]
|
| 75 |
|
| 76 |
def do_nothing(text):
|
|
@@ -106,7 +106,8 @@ def handle_prompt_change(prompt):
|
|
| 106 |
|
| 107 |
return hint_list
|
| 108 |
|
| 109 |
-
def clear_task():
|
|
|
|
| 110 |
return "", "", [], None
|
| 111 |
|
| 112 |
def clear_task_id():
|
|
@@ -165,8 +166,16 @@ with gr.Blocks() as demo:
|
|
| 165 |
cache_image_base64 = gr.Text(visible=False)
|
| 166 |
cache_task_uuid = gr.Text(value="", visible=False)
|
| 167 |
|
| 168 |
-
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
block_image.upload(
|
| 171 |
fn=do_nothing,
|
| 172 |
js=change_button_name_to_generating,
|
|
@@ -193,14 +202,18 @@ with gr.Blocks() as demo:
|
|
| 193 |
js=reset_button_name,
|
| 194 |
inputs=[cacha_empty],
|
| 195 |
outputs=[cacha_empty]
|
| 196 |
-
).then(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
|
| 198 |
# block_image.change(
|
| 199 |
# fn=do_nothing,
|
| 200 |
# js=reset_button_name,
|
| 201 |
# inputs=[cacha_empty],
|
| 202 |
# outputs=[cacha_empty]
|
| 203 |
-
# )
|
| 204 |
|
| 205 |
button_generate.click(
|
| 206 |
fn=do_nothing,
|
|
|
|
| 1 |
import os
|
| 2 |
+
# os.system('pip uninstall -y gradio_fake3d')
|
| 3 |
+
# os.system('pip install gradio_fake3d-0.0.3-py3-none-any.whl')
|
| 4 |
|
| 5 |
import gradio as gr
|
| 6 |
import re
|
| 7 |
from gradio_fake3d import Fake3D
|
| 8 |
from PIL import Image
|
| 9 |
+
from Rodin import Generator, crop_image, log
|
| 10 |
from constant import *
|
| 11 |
|
| 12 |
generator = Generator(USER, PASSWORD, TOKEN)
|
|
|
|
| 61 |
]
|
| 62 |
|
| 63 |
example = [
|
| 64 |
+
"assets/00.png",
|
| 65 |
+
"assets/07.png",
|
| 66 |
+
"assets/08.png",
|
| 67 |
+
"assets/11.png",
|
| 68 |
+
"assets/13.png",
|
| 69 |
+
"assets/21.png",
|
| 70 |
+
"assets/24.PNG",
|
| 71 |
+
"assets/30.png",
|
| 72 |
+
"assets/42.png",
|
| 73 |
+
"assets/46.png",
|
| 74 |
]
|
| 75 |
|
| 76 |
def do_nothing(text):
|
|
|
|
| 106 |
|
| 107 |
return hint_list
|
| 108 |
|
| 109 |
+
def clear_task(task_input=None):
|
| 110 |
+
log("INFO", "Clearing task...")
|
| 111 |
return "", "", [], None
|
| 112 |
|
| 113 |
def clear_task_id():
|
|
|
|
| 166 |
cache_image_base64 = gr.Text(visible=False)
|
| 167 |
cache_task_uuid = gr.Text(value="", visible=False)
|
| 168 |
|
| 169 |
+
block_example = gr.Examples(
|
| 170 |
+
examples=example,
|
| 171 |
+
fn=clear_task,
|
| 172 |
+
inputs=[block_image],
|
| 173 |
+
outputs=[cache_task_uuid, block_prompt, block_prompt_hint, fake3d],
|
| 174 |
+
run_on_click=True,
|
| 175 |
+
label="Examples"
|
| 176 |
+
)
|
| 177 |
+
# blcok_input_example = gr.Gallery(value=example, columns=10, allow_preview=False, interactive=False)
|
| 178 |
+
|
| 179 |
block_image.upload(
|
| 180 |
fn=do_nothing,
|
| 181 |
js=change_button_name_to_generating,
|
|
|
|
| 202 |
js=reset_button_name,
|
| 203 |
inputs=[cacha_empty],
|
| 204 |
outputs=[cacha_empty]
|
| 205 |
+
).then(
|
| 206 |
+
fn=clear_task,
|
| 207 |
+
outputs=[cache_task_uuid, block_prompt, block_prompt_hint, fake3d],
|
| 208 |
+
show_progress="hidden"
|
| 209 |
+
)
|
| 210 |
|
| 211 |
# block_image.change(
|
| 212 |
# fn=do_nothing,
|
| 213 |
# js=reset_button_name,
|
| 214 |
# inputs=[cacha_empty],
|
| 215 |
# outputs=[cacha_empty]
|
| 216 |
+
# )
|
| 217 |
|
| 218 |
button_generate.click(
|
| 219 |
fn=do_nothing,
|