multimodalart HF staff commited on
Commit
342238f
1 Parent(s): 2dbfae1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -20
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
- 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)
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):