Spaces:
Runtime error
Runtime error
chore: Update Gradio UI layout for image generation and processing
Browse files
app.py
CHANGED
|
@@ -192,13 +192,14 @@ print('Loading Finished!')
|
|
| 192 |
|
| 193 |
with gr.Blocks() as demo:
|
| 194 |
with gr.Group():
|
| 195 |
-
with gr.
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
|
|
|
|
|
|
| 200 |
|
| 201 |
-
with gr.Tab("Image Processing"):
|
| 202 |
with gr.Row(variant="panel"):
|
| 203 |
with gr.Column():
|
| 204 |
with gr.Row():
|
|
@@ -219,13 +220,9 @@ with gr.Blocks() as demo:
|
|
| 219 |
with gr.Group():
|
| 220 |
do_remove_background = gr.Checkbox(
|
| 221 |
label="Remove Background", value=True)
|
| 222 |
-
sample_seed = gr.Number(
|
| 223 |
-
value=42, label="Seed Value", precision=0)
|
| 224 |
-
sample_steps = gr.Slider(
|
| 225 |
-
label="Sample Steps", minimum=30, maximum=75, value=75, step=5)
|
| 226 |
with gr.Row():
|
| 227 |
-
|
| 228 |
-
"
|
| 229 |
with gr.Row(variant="panel"):
|
| 230 |
gr.Examples(
|
| 231 |
examples=[os.path.join("examples", img_name) for img_name in sorted(
|
|
@@ -236,7 +233,7 @@ with gr.Blocks() as demo:
|
|
| 236 |
examples_per_page=16
|
| 237 |
)
|
| 238 |
|
| 239 |
-
with gr.Tab("3D Model"):
|
| 240 |
with gr.Column():
|
| 241 |
with gr.Row():
|
| 242 |
with gr.Column():
|
|
@@ -246,6 +243,15 @@ with gr.Blocks() as demo:
|
|
| 246 |
width=379,
|
| 247 |
interactive=False
|
| 248 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
with gr.Row():
|
| 250 |
with gr.Tab("OBJ"):
|
| 251 |
output_model_obj = gr.Model3D(
|
|
@@ -268,13 +274,11 @@ with gr.Blocks() as demo:
|
|
| 268 |
mv_images = gr.State()
|
| 269 |
|
| 270 |
submit_prompt.click(fn=generate_image, inputs=[prompt], outputs=img)
|
| 271 |
-
|
| 272 |
fn=preprocess, inputs=[input_image,
|
| 273 |
do_remove_background], outputs=[processed_image],
|
| 274 |
-
)
|
| 275 |
-
|
| 276 |
-
mv_images, mv_show_images]
|
| 277 |
-
).success(
|
| 278 |
fn=make3d, inputs=[mv_images], outputs=[
|
| 279 |
output_model_obj, output_model_glb]
|
| 280 |
)
|
|
|
|
| 192 |
|
| 193 |
with gr.Blocks() as demo:
|
| 194 |
with gr.Group():
|
| 195 |
+
with gr.Tab("Generate Image and Remove Background"):
|
| 196 |
+
with gr.Row():
|
| 197 |
+
prompt = gr.Textbox(
|
| 198 |
+
label='Enter your prompt (English)', scale=2)
|
| 199 |
+
submit_prompt = gr.Button(
|
| 200 |
+
'Generate Image', scale=1, variant='primary')
|
| 201 |
+
img = gr.Image()
|
| 202 |
|
|
|
|
| 203 |
with gr.Row(variant="panel"):
|
| 204 |
with gr.Column():
|
| 205 |
with gr.Row():
|
|
|
|
| 220 |
with gr.Group():
|
| 221 |
do_remove_background = gr.Checkbox(
|
| 222 |
label="Remove Background", value=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
with gr.Row():
|
| 224 |
+
submit_process = gr.Button(
|
| 225 |
+
"Process Image", elem_id="process", variant="primary")
|
| 226 |
with gr.Row(variant="panel"):
|
| 227 |
gr.Examples(
|
| 228 |
examples=[os.path.join("examples", img_name) for img_name in sorted(
|
|
|
|
| 233 |
examples_per_page=16
|
| 234 |
)
|
| 235 |
|
| 236 |
+
with gr.Tab("Generate 3D Model"):
|
| 237 |
with gr.Column():
|
| 238 |
with gr.Row():
|
| 239 |
with gr.Column():
|
|
|
|
| 243 |
width=379,
|
| 244 |
interactive=False
|
| 245 |
)
|
| 246 |
+
with gr.Row():
|
| 247 |
+
with gr.Group():
|
| 248 |
+
sample_seed = gr.Number(
|
| 249 |
+
value=42, label="Seed Value", precision=0)
|
| 250 |
+
sample_steps = gr.Slider(
|
| 251 |
+
label="Sample Steps", minimum=30, maximum=75, value=75, step=5)
|
| 252 |
+
with gr.Row():
|
| 253 |
+
submit_mesh = gr.Button(
|
| 254 |
+
"Generate 3D Model", elem_id="generate", variant="primary")
|
| 255 |
with gr.Row():
|
| 256 |
with gr.Tab("OBJ"):
|
| 257 |
output_model_obj = gr.Model3D(
|
|
|
|
| 274 |
mv_images = gr.State()
|
| 275 |
|
| 276 |
submit_prompt.click(fn=generate_image, inputs=[prompt], outputs=img)
|
| 277 |
+
submit_process.click(fn=check_input_image, inputs=[input_image]).success(
|
| 278 |
fn=preprocess, inputs=[input_image,
|
| 279 |
do_remove_background], outputs=[processed_image],
|
| 280 |
+
)
|
| 281 |
+
submit_mesh.click(fn=generate_mvs, inputs=[processed_image, sample_steps, sample_seed], outputs=[mv_images, mv_show_images]).success(
|
|
|
|
|
|
|
| 282 |
fn=make3d, inputs=[mv_images], outputs=[
|
| 283 |
output_model_obj, output_model_glb]
|
| 284 |
)
|