Spaces:
Runtime error
Runtime error
Commit
·
342238f
1
Parent(s):
2dbfae1
Update app.py
Browse files
app.py
CHANGED
@@ -93,28 +93,27 @@ def load_captioning(uploaded_images, option):
|
|
93 |
raise gr.Error(
|
94 |
f"For now, only {MAX_IMAGES} or less images are allowed for training"
|
95 |
)
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
return updates
|
115 |
|
116 |
def check_removed_and_restart(images):
|
117 |
-
visible =
|
118 |
return [gr.update(visible=visible) for _ in range(3)]
|
119 |
|
120 |
def make_options_visible(option):
|
|
|
93 |
raise gr.Error(
|
94 |
f"For now, only {MAX_IMAGES} or less images are allowed for training"
|
95 |
)
|
96 |
+
# Update for the captioning_area
|
97 |
+
for _ in range(3):
|
98 |
+
updates.append(gr.update(visible=True))
|
99 |
+
# Update visibility and image for each captioning row and image
|
100 |
+
for i in range(1, MAX_IMAGES + 1):
|
101 |
+
# Determine if the current row and image should be visible
|
102 |
+
visible = i <= len(uploaded_images)
|
103 |
+
|
104 |
+
# Update visibility of the captioning row
|
105 |
+
updates.append(gr.update(visible=visible))
|
106 |
+
|
107 |
+
# Update for image component - display image if available, otherwise hide
|
108 |
+
image_value = uploaded_images[i - 1] if visible else None
|
109 |
+
updates.append(gr.update(value=image_value, visible=visible))
|
110 |
+
|
111 |
+
text_value = option if visible else None
|
112 |
+
updates.append(gr.update(value=text_value, visible=visible))
|
113 |
+
return updates
|
|
|
114 |
|
115 |
def check_removed_and_restart(images):
|
116 |
+
visible = len(images) > 1 if images is not None else False
|
117 |
return [gr.update(visible=visible) for _ in range(3)]
|
118 |
|
119 |
def make_options_visible(option):
|