File size: 867 Bytes
bc55c43
 
 
 
d97b7a0
 
 
 
 
 
 
 
 
 
bc55c43
d97b7a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bc55c43
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python

import gradio as gr


def update_ui(task):
    return (
        gr.update(visible=task == "text"),
        gr.update(visible=task == "image"),
        gr.update(visible=task == "text"),
        gr.update(visible=task == "image"),
    )


with gr.Blocks() as demo:
    tasks = gr.Dropdown(choices=["text", "image"], value="text")
    text = gr.Textbox()
    image = gr.Image(height=400, visible=False)

    with gr.Row() as text_examples:
        gr.Examples(examples=["a", "b"], inputs=text)
    with gr.Row(visible=False) as image_examples:
        gr.Examples(examples=["dogs.jpg"], inputs=image)

    tasks.change(
        fn=update_ui,
        inputs=tasks,
        outputs=[
            text,
            image,
            text_examples,
            image_examples,
        ],
    )


if __name__ == "__main__":
    demo.queue().launch()