[martin-dev] fix example 3; no cache for now
Browse files- demo/launch_gradio.py +19 -17
demo/launch_gradio.py
CHANGED
|
@@ -22,6 +22,16 @@ models_cache: Dict[str, Any] = {}
|
|
| 22 |
current_model_selection: Optional[ModelSelection] = None
|
| 23 |
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
def read_layer_spec(spec_file_path: str) -> List[str]:
|
| 26 |
"""Read available layers from the model spec file.
|
| 27 |
|
|
@@ -583,6 +593,15 @@ def create_demo() -> gr.Blocks:
|
|
| 583 |
lines=3
|
| 584 |
)
|
| 585 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 586 |
top_k_slider = gr.Slider(
|
| 587 |
minimum=1,
|
| 588 |
maximum=20,
|
|
@@ -625,23 +644,6 @@ def create_demo() -> gr.Blocks:
|
|
| 625 |
outputs=[plot_output, info_output]
|
| 626 |
)
|
| 627 |
|
| 628 |
-
# Custom interactive examples (safe for GPU Spaces)
|
| 629 |
-
gr.Markdown("### Example Prompts (Click to Insert)")
|
| 630 |
-
|
| 631 |
-
with gr.Row():
|
| 632 |
-
gr.Button("Example 1").click(
|
| 633 |
-
fn=lambda: ("What is in this image? Describe in one word.", None, None),
|
| 634 |
-
outputs=[instruction_input, image1_input, image2_input]
|
| 635 |
-
)
|
| 636 |
-
gr.Button("Example 2").click(
|
| 637 |
-
fn=lambda: ("Describe the main object in the picture in one word.", None, None),
|
| 638 |
-
outputs=[instruction_input, image1_input, image2_input]
|
| 639 |
-
)
|
| 640 |
-
gr.Button("Example 3").click(
|
| 641 |
-
fn=lambda: ("What color is the dominant object? Describe in one word.", None, None),
|
| 642 |
-
outputs=[instruction_input, image1_input, image2_input]
|
| 643 |
-
)
|
| 644 |
-
|
| 645 |
return demo
|
| 646 |
|
| 647 |
|
|
|
|
| 22 |
current_model_selection: Optional[ModelSelection] = None
|
| 23 |
|
| 24 |
|
| 25 |
+
def example1():
|
| 26 |
+
return "What is in this image? Describe in one word.", None, None
|
| 27 |
+
|
| 28 |
+
def example2():
|
| 29 |
+
return "Describe the main object in the picture in one word.", None, None
|
| 30 |
+
|
| 31 |
+
def example3():
|
| 32 |
+
return "What color is the dominant object? Describe in one word.", None, None
|
| 33 |
+
|
| 34 |
+
|
| 35 |
def read_layer_spec(spec_file_path: str) -> List[str]:
|
| 36 |
"""Read available layers from the model spec file.
|
| 37 |
|
|
|
|
| 593 |
lines=3
|
| 594 |
)
|
| 595 |
|
| 596 |
+
# GPU-safe interactive examples
|
| 597 |
+
gr.Markdown("### Example Prompts (Click to Insert)")
|
| 598 |
+
gr.Button("Example 1").click(fn=example1,
|
| 599 |
+
outputs=[instruction_input, image1_input, image2_input])
|
| 600 |
+
gr.Button("Example 2").click(fn=example2,
|
| 601 |
+
outputs=[instruction_input, image1_input, image2_input])
|
| 602 |
+
gr.Button("Example 3").click(fn=example3,
|
| 603 |
+
outputs=[instruction_input, image1_input, image2_input])
|
| 604 |
+
|
| 605 |
top_k_slider = gr.Slider(
|
| 606 |
minimum=1,
|
| 607 |
maximum=20,
|
|
|
|
| 644 |
outputs=[plot_output, info_output]
|
| 645 |
)
|
| 646 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 647 |
return demo
|
| 648 |
|
| 649 |
|