multimodalart HF staff commited on
Commit
48fc3d0
1 Parent(s): fe4af0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -65,16 +65,17 @@ def load_captioning(uploaded_images, concept_sentence):
65
  # Update for image component - display image if available, otherwise hide
66
  image_value = uploaded_images[i - 1] if visible else None
67
  updates.append(gr.update(value=image_value, visible=visible))
68
-
69
- base_name = image_value.rsplit('.', 1)[0]
70
 
71
- corresponding_txt = base_name + '.txt'
72
  corresponding_caption = False
73
- if corresponding_txt in txt_files:
74
- with open(corresponding_txt, 'r') as file:
75
- corresponding_caption = file.read()
 
 
 
 
76
  # Update value of captioning area
77
- text_value = corresponding_caption if corresponding_caption else "[trigger]" if visible and concept_sentence else None
78
  updates.append(gr.update(value=text_value, visible=visible))
79
 
80
  # Update for the sample caption area
 
65
  # Update for image component - display image if available, otherwise hide
66
  image_value = uploaded_images[i - 1] if visible else None
67
  updates.append(gr.update(value=image_value, visible=visible))
 
 
68
 
 
69
  corresponding_caption = False
70
+ if(image_value):
71
+ base_name = image_value.rsplit('.', 1)[0]
72
+
73
+ corresponding_txt = base_name + '.txt'
74
+ if corresponding_txt in txt_files:
75
+ with open(corresponding_txt, 'r') as file:
76
+ corresponding_caption = file.read()
77
  # Update value of captioning area
78
+ text_value = corresponding_caption if visible and corresponding_caption else "[trigger]" if visible and concept_sentence else None
79
  updates.append(gr.update(value=text_value, visible=visible))
80
 
81
  # Update for the sample caption area