Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
b9dd0a0
1
Parent(s):
e70400c
wip
Browse files- app.py +3 -8
- utils/ui_utils.py +15 -18
app.py
CHANGED
@@ -50,12 +50,7 @@ with gr.Blocks() as demo:
|
|
50 |
# Link radio button change to visibility update function
|
51 |
face_input_type.change(
|
52 |
fn=update_input_visibility,
|
53 |
-
inputs=[
|
54 |
-
face_input_type,
|
55 |
-
face_img_upload,
|
56 |
-
face_url_input,
|
57 |
-
face_base64_input,
|
58 |
-
],
|
59 |
outputs=[face_img_upload, face_url_input, face_base64_input],
|
60 |
queue=False,
|
61 |
)
|
@@ -103,7 +98,7 @@ with gr.Blocks() as demo:
|
|
103 |
# Link radio button change to visibility update function
|
104 |
age_input_type.change(
|
105 |
fn=update_input_visibility,
|
106 |
-
inputs=[age_input_type
|
107 |
outputs=[age_img_upload, age_url_input, age_base64_input],
|
108 |
queue=False,
|
109 |
)
|
@@ -145,7 +140,7 @@ with gr.Blocks() as demo:
|
|
145 |
# Link radio button change to visibility update function
|
146 |
obj_input_type.change(
|
147 |
fn=update_input_visibility,
|
148 |
-
inputs=[obj_input_type
|
149 |
outputs=[obj_img_upload, obj_url_input, obj_base64_input],
|
150 |
queue=False,
|
151 |
)
|
|
|
50 |
# Link radio button change to visibility update function
|
51 |
face_input_type.change(
|
52 |
fn=update_input_visibility,
|
53 |
+
inputs=[face_input_type],
|
|
|
|
|
|
|
|
|
|
|
54 |
outputs=[face_img_upload, face_url_input, face_base64_input],
|
55 |
queue=False,
|
56 |
)
|
|
|
98 |
# Link radio button change to visibility update function
|
99 |
age_input_type.change(
|
100 |
fn=update_input_visibility,
|
101 |
+
inputs=[age_input_type],
|
102 |
outputs=[age_img_upload, age_url_input, age_base64_input],
|
103 |
queue=False,
|
104 |
)
|
|
|
140 |
# Link radio button change to visibility update function
|
141 |
obj_input_type.change(
|
142 |
fn=update_input_visibility,
|
143 |
+
inputs=[obj_input_type],
|
144 |
outputs=[obj_img_upload, obj_url_input, obj_base64_input],
|
145 |
queue=False,
|
146 |
)
|
utils/ui_utils.py
CHANGED
@@ -1,40 +1,37 @@
|
|
1 |
# Utility functions for UI components
|
2 |
import gradio as gr
|
3 |
|
4 |
-
def update_input_visibility(choice
|
5 |
"""
|
6 |
-
|
7 |
|
8 |
Args:
|
9 |
choice (str): The selected input method ("Upload File", "Enter URL", "Enter Base64").
|
10 |
-
upload_component (gr.components): The Gradio component for file upload.
|
11 |
-
url_component (gr.components): The Gradio component for URL input.
|
12 |
-
base64_component (gr.components): The Gradio component for Base64 input.
|
13 |
|
14 |
Returns:
|
15 |
-
tuple: A tuple containing
|
16 |
"""
|
17 |
if choice == "Upload File":
|
18 |
return (
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
)
|
23 |
elif choice == "Enter URL":
|
24 |
return (
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
)
|
29 |
elif choice == "Enter Base64":
|
30 |
return (
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
)
|
35 |
else: # Default or unexpected
|
36 |
return (
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
)
|
|
|
1 |
# Utility functions for UI components
|
2 |
import gradio as gr
|
3 |
|
4 |
+
def update_input_visibility(choice):
|
5 |
"""
|
6 |
+
Returns updates to the visibility of input components based on the selected input method.
|
7 |
|
8 |
Args:
|
9 |
choice (str): The selected input method ("Upload File", "Enter URL", "Enter Base64").
|
|
|
|
|
|
|
10 |
|
11 |
Returns:
|
12 |
+
tuple: A tuple containing Gradio Update objects for the visibility of the input components.
|
13 |
"""
|
14 |
if choice == "Upload File":
|
15 |
return (
|
16 |
+
gr.update(visible=True),
|
17 |
+
gr.update(visible=False),
|
18 |
+
gr.update(visible=False),
|
19 |
)
|
20 |
elif choice == "Enter URL":
|
21 |
return (
|
22 |
+
gr.update(visible=False),
|
23 |
+
gr.update(visible=True),
|
24 |
+
gr.update(visible=False),
|
25 |
)
|
26 |
elif choice == "Enter Base64":
|
27 |
return (
|
28 |
+
gr.update(visible=False),
|
29 |
+
gr.update(visible=False),
|
30 |
+
gr.update(visible=True),
|
31 |
)
|
32 |
else: # Default or unexpected
|
33 |
return (
|
34 |
+
gr.update(visible=True),
|
35 |
+
gr.update(visible=False),
|
36 |
+
gr.update(visible=False),
|
37 |
)
|