Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -181,8 +181,11 @@ def generate(image, mc_resolution, formats=["obj", "glb"]):
|
|
| 181 |
|
| 182 |
return mesh_path_obj.name, mesh_path_glb.name
|
| 183 |
|
| 184 |
-
def run_example(image, seed, do_remove_background, foreground_ratio, mc_resolution, text_prompt=None):
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
| 186 |
preprocessed = preprocess(image_pil, do_remove_background, foreground_ratio)
|
| 187 |
mesh_name_obj, mesh_name_glb = generate(preprocessed, 256, ["obj", "glb"])
|
| 188 |
return preprocessed, mesh_name_obj, mesh_name_glb
|
|
@@ -206,6 +209,9 @@ with gr.Blocks() as demo:
|
|
| 206 |
placeholder="Enter Positive Prompt"
|
| 207 |
)
|
| 208 |
seed = gr.Textbox(label="Random Seed", value=0)
|
|
|
|
|
|
|
|
|
|
| 209 |
processed_image = gr.Image(label="Processed Image", interactive=False, visible=False)
|
| 210 |
with gr.Row():
|
| 211 |
with gr.Group():
|
|
@@ -244,7 +250,7 @@ with gr.Blocks() as demo:
|
|
| 244 |
|
| 245 |
submit.click(fn=check_input_image, inputs=[input_image]).success(
|
| 246 |
fn=run_example,
|
| 247 |
-
inputs=[input_image, seed, do_remove_background, foreground_ratio, mc_resolution, text_prompt],
|
| 248 |
outputs=[processed_image, output_model_obj, output_model_glb],
|
| 249 |
# outputs=[output_model_obj, output_model_glb],
|
| 250 |
)
|
|
|
|
| 181 |
|
| 182 |
return mesh_path_obj.name, mesh_path_glb.name
|
| 183 |
|
| 184 |
+
def run_example(image, seed, use_image, do_remove_background, foreground_ratio, mc_resolution, text_prompt=None):
|
| 185 |
+
if use_image:
|
| 186 |
+
image_pil = generate_image_from_text(encoded_image=image, seed=seed, pos_prompt=text_prompt)
|
| 187 |
+
else:
|
| 188 |
+
image_pil = image
|
| 189 |
preprocessed = preprocess(image_pil, do_remove_background, foreground_ratio)
|
| 190 |
mesh_name_obj, mesh_name_glb = generate(preprocessed, 256, ["obj", "glb"])
|
| 191 |
return preprocessed, mesh_name_obj, mesh_name_glb
|
|
|
|
| 209 |
placeholder="Enter Positive Prompt"
|
| 210 |
)
|
| 211 |
seed = gr.Textbox(label="Random Seed", value=0)
|
| 212 |
+
use_image = gr.Checkbox(
|
| 213 |
+
label="Enhance Image", value=True
|
| 214 |
+
)
|
| 215 |
processed_image = gr.Image(label="Processed Image", interactive=False, visible=False)
|
| 216 |
with gr.Row():
|
| 217 |
with gr.Group():
|
|
|
|
| 250 |
|
| 251 |
submit.click(fn=check_input_image, inputs=[input_image]).success(
|
| 252 |
fn=run_example,
|
| 253 |
+
inputs=[input_image, seed, use_image, do_remove_background, foreground_ratio, mc_resolution, text_prompt],
|
| 254 |
outputs=[processed_image, output_model_obj, output_model_glb],
|
| 255 |
# outputs=[output_model_obj, output_model_glb],
|
| 256 |
)
|