Spaces:
Runtime error
Runtime error
Commit
·
2dbfae1
1
Parent(s):
2f7e080
Update app.py
Browse files
app.py
CHANGED
|
@@ -87,30 +87,31 @@ def load_captioning(uploaded_images, option):
|
|
| 87 |
updates = []
|
| 88 |
if len(uploaded_images) <= 1:
|
| 89 |
raise gr.Error(
|
| 90 |
-
"
|
| 91 |
)
|
| 92 |
-
|
| 93 |
raise gr.Error(
|
| 94 |
-
f"
|
| 95 |
)
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
|
|
|
| 114 |
|
| 115 |
def check_removed_and_restart(images):
|
| 116 |
visible = bool(images)
|
|
|
|
| 87 |
updates = []
|
| 88 |
if len(uploaded_images) <= 1:
|
| 89 |
raise gr.Error(
|
| 90 |
+
"Please upload at least 2 images to train your model (the ideal number with default settings is between 4-30)"
|
| 91 |
)
|
| 92 |
+
elif len(uploaded_images) > MAX_IMAGES:
|
| 93 |
raise gr.Error(
|
| 94 |
+
f"For now, only {MAX_IMAGES} or less images are allowed for training"
|
| 95 |
)
|
| 96 |
+
else:
|
| 97 |
+
# Update for the captioning_area
|
| 98 |
+
for _ in range(3):
|
| 99 |
+
updates.append(gr.update(visible=True))
|
| 100 |
+
# Update visibility and image for each captioning row and image
|
| 101 |
+
for i in range(1, MAX_IMAGES + 1):
|
| 102 |
+
# Determine if the current row and image should be visible
|
| 103 |
+
visible = i <= len(uploaded_images)
|
| 104 |
+
|
| 105 |
+
# Update visibility of the captioning row
|
| 106 |
+
updates.append(gr.update(visible=visible))
|
| 107 |
+
|
| 108 |
+
# Update for image component - display image if available, otherwise hide
|
| 109 |
+
image_value = uploaded_images[i - 1] if visible else None
|
| 110 |
+
updates.append(gr.update(value=image_value, visible=visible))
|
| 111 |
+
|
| 112 |
+
text_value = option if visible else None
|
| 113 |
+
updates.append(gr.update(value=text_value, visible=visible))
|
| 114 |
+
return updates
|
| 115 |
|
| 116 |
def check_removed_and_restart(images):
|
| 117 |
visible = bool(images)
|