Spaces:
Sleeping
Sleeping
VictorGearhead
commited on
Commit
•
c34d3bc
1
Parent(s):
433779c
Update app.py
Browse files
app.py
CHANGED
@@ -169,17 +169,14 @@ def generate_caption(K, image_path):
|
|
169 |
image__path = 'Images/' + image_path
|
170 |
# image = Image.open('Images/' + image_path).convert("RGB")
|
171 |
image = process_image_from_zip('Images.zip', image__path)
|
172 |
-
|
173 |
-
ax.imshow(image)
|
174 |
-
ax.axis('off')
|
175 |
-
st.pyplot(fig)
|
176 |
|
177 |
valid_img_df = validation[validation['image']==image_path]
|
178 |
|
179 |
actual_caption_list = valid_img_df['caption'].tolist()
|
180 |
filtered_caption_list = [word for word in actual_caption_list[0] if word not in ['<start>', '<end>', '<cell>']]
|
181 |
actual_caption = " ".join(filtered_caption_list)
|
182 |
-
|
183 |
|
184 |
valid_img_embed = validation[validation['image'] == image_path]
|
185 |
|
@@ -222,7 +219,11 @@ def generate_caption(K, image_path):
|
|
222 |
|
223 |
|
224 |
filtered_caption_list = [word for word in predicted_sentence if word not in ['<start>', '<end>', '<cell>']]
|
225 |
-
|
|
|
|
|
|
|
|
|
226 |
st.write("Predicted Caption: ", " ".join(filtered_caption_list))
|
227 |
|
228 |
|
@@ -238,5 +239,5 @@ if generate_caption_button:
|
|
238 |
generate_caption(1, random_image)
|
239 |
|
240 |
except RuntimeError as e:
|
241 |
-
|
242 |
|
|
|
169 |
image__path = 'Images/' + image_path
|
170 |
# image = Image.open('Images/' + image_path).convert("RGB")
|
171 |
image = process_image_from_zip('Images.zip', image__path)
|
172 |
+
|
|
|
|
|
|
|
173 |
|
174 |
valid_img_df = validation[validation['image']==image_path]
|
175 |
|
176 |
actual_caption_list = valid_img_df['caption'].tolist()
|
177 |
filtered_caption_list = [word for word in actual_caption_list[0] if word not in ['<start>', '<end>', '<cell>']]
|
178 |
actual_caption = " ".join(filtered_caption_list)
|
179 |
+
|
180 |
|
181 |
valid_img_embed = validation[validation['image'] == image_path]
|
182 |
|
|
|
219 |
|
220 |
|
221 |
filtered_caption_list = [word for word in predicted_sentence if word not in ['<start>', '<end>', '<cell>']]
|
222 |
+
fig, ax = plt.subplots()
|
223 |
+
ax.imshow(image)
|
224 |
+
ax.axis('off')
|
225 |
+
st.pyplot(fig)
|
226 |
+
st.write("Actual Caption: ", actual_caption)
|
227 |
st.write("Predicted Caption: ", " ".join(filtered_caption_list))
|
228 |
|
229 |
|
|
|
239 |
generate_caption(1, random_image)
|
240 |
|
241 |
except RuntimeError as e:
|
242 |
+
st.write("TRY AGAIN")
|
243 |
|