Spaces:
Runtime error
Runtime error
lionelgarnier
commited on
Commit
·
3b49492
1
Parent(s):
67e2964
preprocess image
Browse files
app.py
CHANGED
@@ -58,11 +58,14 @@ def start_session(req: gr.Request):
|
|
58 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
59 |
os.makedirs(user_dir, exist_ok=True)
|
60 |
|
61 |
-
|
62 |
def end_session(req: gr.Request):
|
63 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
64 |
shutil.rmtree(user_dir)
|
65 |
|
|
|
|
|
|
|
|
|
66 |
|
67 |
|
68 |
@spaces.GPU()
|
@@ -449,10 +452,12 @@ def create_interface():
|
|
449 |
max_length=2048,
|
450 |
)
|
451 |
visual_button = gr.Button("Create visual with Flux")
|
452 |
-
|
453 |
generated_image = gr.Image(show_label=False)
|
454 |
-
gen3d_button = gr.Button("Create 3D visual with Trellis")
|
455 |
|
|
|
|
|
|
|
|
|
456 |
video_output = gr.Video(label="Generated 3D Asset", autoplay=True, loop=True, height=300)
|
457 |
# model_output = LitModel3D(label="Extracted GLB/Gaussian", exposure=10.0, height=300)
|
458 |
|
@@ -550,10 +555,17 @@ def create_interface():
|
|
550 |
outputs=[generated_image, message_box]
|
551 |
)
|
552 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
553 |
gr.on(
|
554 |
triggers=[gen3d_button.click],
|
555 |
fn=image_to_3d,
|
556 |
-
inputs=[
|
557 |
outputs=[output_state, video_output],
|
558 |
).then(
|
559 |
# Update button states after successful 3D generation
|
|
|
58 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
59 |
os.makedirs(user_dir, exist_ok=True)
|
60 |
|
|
|
61 |
def end_session(req: gr.Request):
|
62 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
63 |
shutil.rmtree(user_dir)
|
64 |
|
65 |
+
def preprocess_image(image: Image.Image) -> Image.Image:
|
66 |
+
processed_image = pipeline.preprocess_image(image)
|
67 |
+
return processed_image
|
68 |
+
|
69 |
|
70 |
|
71 |
@spaces.GPU()
|
|
|
452 |
max_length=2048,
|
453 |
)
|
454 |
visual_button = gr.Button("Create visual with Flux")
|
|
|
455 |
generated_image = gr.Image(show_label=False)
|
|
|
456 |
|
457 |
+
preprocessed_button = gr.Button("Create 3D visual with Trellis")
|
458 |
+
preprocessed_image = gr.Image(show_label=False)
|
459 |
+
|
460 |
+
gen3d_button = gr.Button("Create 3D visual with Trellis")
|
461 |
video_output = gr.Video(label="Generated 3D Asset", autoplay=True, loop=True, height=300)
|
462 |
# model_output = LitModel3D(label="Extracted GLB/Gaussian", exposure=10.0, height=300)
|
463 |
|
|
|
555 |
outputs=[generated_image, message_box]
|
556 |
)
|
557 |
|
558 |
+
gr.on(
|
559 |
+
triggers=[preprocessed_button.click],
|
560 |
+
fn=preprocess_image,
|
561 |
+
inputs=[generated_image],
|
562 |
+
outputs=[preprocessed_image, message_box]
|
563 |
+
)
|
564 |
+
|
565 |
gr.on(
|
566 |
triggers=[gen3d_button.click],
|
567 |
fn=image_to_3d,
|
568 |
+
inputs=[preprocessed_image, trellis_seed, ss_guidance_strength, ss_sampling_steps, slat_guidance_strength, slat_sampling_steps],
|
569 |
outputs=[output_state, video_output],
|
570 |
).then(
|
571 |
# Update button states after successful 3D generation
|