Spaces:
Configuration error
Configuration error
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -700,6 +700,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="orange", neutral_hue="slate"),
|
|
| 700 |
with gr.Row():
|
| 701 |
with gr.Column(scale=1, min_width=360):
|
| 702 |
multiimage_prompt = gr.Gallery(label="Multi-View Images", format="png", type="pil", height=400, columns=3, interactive=True)
|
|
|
|
| 703 |
|
| 704 |
resolution = gr.Radio(["512", "1024", "1536"], label="Resolution", value="1024")
|
| 705 |
seed = gr.Slider(0, MAX_SEED, label="Seed", value=0, step=1)
|
|
@@ -754,11 +755,31 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="orange", neutral_hue="slate"),
|
|
| 754 |
output_buf = gr.State()
|
| 755 |
processed_buf = gr.State()
|
| 756 |
render_buf = gr.State()
|
|
|
|
| 757 |
|
| 758 |
|
| 759 |
# Handlers
|
| 760 |
demo.load(start_session)
|
| 761 |
demo.unload(end_session)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 762 |
multiimage_prompt.upload(
|
| 763 |
preprocess_images,
|
| 764 |
inputs=[multiimage_prompt],
|
|
|
|
| 700 |
with gr.Row():
|
| 701 |
with gr.Column(scale=1, min_width=360):
|
| 702 |
multiimage_prompt = gr.Gallery(label="Multi-View Images", format="png", type="pil", height=400, columns=3, interactive=True)
|
| 703 |
+
remove_img_btn = gr.Button("Remove Selected Image", size="sm", variant="secondary")
|
| 704 |
|
| 705 |
resolution = gr.Radio(["512", "1024", "1536"], label="Resolution", value="1024")
|
| 706 |
seed = gr.Slider(0, MAX_SEED, label="Seed", value=0, step=1)
|
|
|
|
| 755 |
output_buf = gr.State()
|
| 756 |
processed_buf = gr.State()
|
| 757 |
render_buf = gr.State()
|
| 758 |
+
selected_img_idx = gr.State(value=None)
|
| 759 |
|
| 760 |
|
| 761 |
# Handlers
|
| 762 |
demo.load(start_session)
|
| 763 |
demo.unload(end_session)
|
| 764 |
+
|
| 765 |
+
def on_gallery_select(evt: gr.SelectData):
|
| 766 |
+
return evt.index
|
| 767 |
+
|
| 768 |
+
def remove_selected_image(images, idx):
|
| 769 |
+
if images is None or idx is None or not images:
|
| 770 |
+
return images, None
|
| 771 |
+
images = list(images)
|
| 772 |
+
if idx < len(images):
|
| 773 |
+
images.pop(idx)
|
| 774 |
+
return images, None
|
| 775 |
+
|
| 776 |
+
multiimage_prompt.select(on_gallery_select, outputs=[selected_img_idx])
|
| 777 |
+
remove_img_btn.click(
|
| 778 |
+
remove_selected_image,
|
| 779 |
+
inputs=[multiimage_prompt, selected_img_idx],
|
| 780 |
+
outputs=[multiimage_prompt, selected_img_idx],
|
| 781 |
+
)
|
| 782 |
+
|
| 783 |
multiimage_prompt.upload(
|
| 784 |
preprocess_images,
|
| 785 |
inputs=[multiimage_prompt],
|