Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -278,19 +278,30 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
278 |
lines=3
|
279 |
)
|
280 |
|
281 |
-
# Examples
|
282 |
if example_images:
|
283 |
-
gr.
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
|
295 |
with gr.Accordion("Image Generation Settings", open=False):
|
296 |
with gr.Row():
|
@@ -343,16 +354,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
343 |
slat_sampling_steps = gr.Slider(1, 50, label="Latent Sampling Steps", value=12, step=1)
|
344 |
|
345 |
generate_3d_btn = gr.Button("Generate 3D")
|
346 |
-
|
347 |
-
gr.Examples(
|
348 |
-
examples=example_images,
|
349 |
-
inputs=image_prompt,
|
350 |
-
outputs=[trial_id, image_prompt],
|
351 |
-
fn=preprocess_image,
|
352 |
-
cache_examples=True,
|
353 |
-
label="Click on an example to load it"
|
354 |
-
)
|
355 |
-
|
356 |
|
357 |
with gr.Accordion("GLB Extraction Settings", open=False):
|
358 |
mesh_simplify = gr.Slider(0.9, 0.98, label="Simplify", value=0.95, step=0.01)
|
@@ -379,7 +380,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
379 |
outputs=[trial_id, image_prompt]
|
380 |
)
|
381 |
|
382 |
-
# 나머지 핸들러들
|
383 |
image_prompt.upload(
|
384 |
preprocess_image,
|
385 |
inputs=[image_prompt],
|
@@ -431,6 +432,7 @@ if __name__ == "__main__":
|
|
431 |
# CUDA 메모리 초기화
|
432 |
if torch.cuda.is_available():
|
433 |
torch.cuda.empty_cache()
|
|
|
434 |
|
435 |
# 초기 이미지 전처리 테스트
|
436 |
try:
|
@@ -440,7 +442,12 @@ if __name__ == "__main__":
|
|
440 |
print(f"Warning: Initial preprocessing test failed: {e}")
|
441 |
|
442 |
# Gradio 인터페이스 실행
|
443 |
-
demo.launch(
|
|
|
|
|
|
|
|
|
|
|
444 |
|
445 |
except Exception as e:
|
446 |
print(f"Error during initialization: {e}")
|
|
|
278 |
lines=3
|
279 |
)
|
280 |
|
281 |
+
# Examples 갤러리를 text_prompt 아래로 이동
|
282 |
if example_images:
|
283 |
+
with gr.Row():
|
284 |
+
gallery = gr.Gallery(
|
285 |
+
value=example_images,
|
286 |
+
label="Example Images",
|
287 |
+
show_label=True,
|
288 |
+
elem_id="gallery",
|
289 |
+
columns=[3],
|
290 |
+
rows=[2],
|
291 |
+
height=200,
|
292 |
+
allow_preview=True
|
293 |
+
).style(grid=3)
|
294 |
+
|
295 |
+
# Gallery 클릭 이벤트 추가
|
296 |
+
def load_example(evt: gr.SelectData):
|
297 |
+
return example_images[evt.index]
|
298 |
+
|
299 |
+
gallery.select(
|
300 |
+
load_example,
|
301 |
+
None,
|
302 |
+
image_prompt,
|
303 |
+
show_progress=True
|
304 |
+
)
|
305 |
|
306 |
with gr.Accordion("Image Generation Settings", open=False):
|
307 |
with gr.Row():
|
|
|
354 |
slat_sampling_steps = gr.Slider(1, 50, label="Latent Sampling Steps", value=12, step=1)
|
355 |
|
356 |
generate_3d_btn = gr.Button("Generate 3D")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
|
358 |
with gr.Accordion("GLB Extraction Settings", open=False):
|
359 |
mesh_simplify = gr.Slider(0.9, 0.98, label="Simplify", value=0.95, step=0.01)
|
|
|
380 |
outputs=[trial_id, image_prompt]
|
381 |
)
|
382 |
|
383 |
+
# 나머지 핸들러들
|
384 |
image_prompt.upload(
|
385 |
preprocess_image,
|
386 |
inputs=[image_prompt],
|
|
|
432 |
# CUDA 메모리 초기화
|
433 |
if torch.cuda.is_available():
|
434 |
torch.cuda.empty_cache()
|
435 |
+
torch.cuda.synchronize()
|
436 |
|
437 |
# 초기 이미지 전처리 테스트
|
438 |
try:
|
|
|
442 |
print(f"Warning: Initial preprocessing test failed: {e}")
|
443 |
|
444 |
# Gradio 인터페이스 실행
|
445 |
+
demo.launch(
|
446 |
+
allowed_paths=[PERSISTENT_DIR],
|
447 |
+
enable_queue=True,
|
448 |
+
max_threads=4,
|
449 |
+
show_error=True
|
450 |
+
)
|
451 |
|
452 |
except Exception as e:
|
453 |
print(f"Error during initialization: {e}")
|