Update app.py
Browse files
app.py
CHANGED
@@ -49,9 +49,9 @@ def display_image_from_url(image_url):
|
|
49 |
|
50 |
def toggle_inputs(input_type):
|
51 |
if input_type == "URL":
|
52 |
-
return gr.update(visible=True
|
53 |
else:
|
54 |
-
return gr.update(visible=False), gr.update(visible=False), gr.update(visible=True
|
55 |
|
56 |
sample_image = Image.open("./kittens.jpeg")
|
57 |
sample_labels = "a photo of a man, a photo of a dog, cats, two cats"
|
@@ -65,10 +65,10 @@ with gr.Blocks() as demo:
|
|
65 |
""")
|
66 |
|
67 |
input_type = gr.Radio(choices=["URL", "Upload"], label="Input Type")
|
68 |
-
image_url = gr.Textbox(value= 'https://huggingface.co/spaces/vsrinivas/Determine_Best_Label_from_Set_of_Given_Labels/resolve/main/kittens.jpeg', label="
|
69 |
-
url_image = gr.Image(value=sample_image,type="pil", label="
|
70 |
-
image_upload = gr.Image(value=sample_image,type="pil", label="
|
71 |
-
labels = gr.Textbox(value=sample_labels, label="
|
72 |
|
73 |
input_type.change(fn=toggle_inputs, inputs=input_type, outputs=[image_url, url_image, image_upload, labels])
|
74 |
image_url.change(fn=display_image_from_url, inputs=image_url, outputs=url_image)
|
|
|
49 |
|
50 |
def toggle_inputs(input_type):
|
51 |
if input_type == "URL":
|
52 |
+
return gr.update(visible=True), gr.update(visible=True), gr.update(visible=False), gr.update(visible=True)
|
53 |
else:
|
54 |
+
return gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=True)
|
55 |
|
56 |
sample_image = Image.open("./kittens.jpeg")
|
57 |
sample_labels = "a photo of a man, a photo of a dog, cats, two cats"
|
|
|
65 |
""")
|
66 |
|
67 |
input_type = gr.Radio(choices=["URL", "Upload"], label="Input Type")
|
68 |
+
image_url = gr.Textbox(value= 'https://huggingface.co/spaces/vsrinivas/Determine_Best_Label_from_Set_of_Given_Labels/resolve/main/kittens.jpeg', label="Type-in/ Paste Image URL", visible=False)
|
69 |
+
url_image = gr.Image(value=sample_image,type="pil", label="URL Image", visible=False)
|
70 |
+
image_upload = gr.Image(value=sample_image,type="pil", label="Uploaded Image", visible=False)
|
71 |
+
labels = gr.Textbox(value=sample_labels, label="Type in your labels seperated by comma(',')", visible=False, lines=2)
|
72 |
|
73 |
input_type.change(fn=toggle_inputs, inputs=input_type, outputs=[image_url, url_image, image_upload, labels])
|
74 |
image_url.change(fn=display_image_from_url, inputs=image_url, outputs=url_image)
|