Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,13 +25,19 @@ def get_caption(image_in):
|
|
| 25 |
|
| 26 |
with open(kosmos2_result[1], 'r') as f:
|
| 27 |
data = json.load(f)
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
# Find the last occurrence of "."
|
| 31 |
-
last_period_index =
|
| 32 |
|
| 33 |
# Truncate the string up to the last period
|
| 34 |
-
truncated_caption =
|
| 35 |
|
| 36 |
# print(truncated_caption)
|
| 37 |
print(f"\n—\nIMAGE CAPTION: {truncated_caption}")
|
|
|
|
| 25 |
|
| 26 |
with open(kosmos2_result[1], 'r') as f:
|
| 27 |
data = json.load(f)
|
| 28 |
+
|
| 29 |
+
reconstructed_sentence = []
|
| 30 |
+
for sublist in data:
|
| 31 |
+
reconstructed_sentence.append(sublist[0])
|
| 32 |
+
|
| 33 |
+
full_sentence = ' '.join(reconstructed_sentence)
|
| 34 |
+
print(full_sentence)
|
| 35 |
|
| 36 |
# Find the last occurrence of "."
|
| 37 |
+
last_period_index = full_sentence.rfind('.')
|
| 38 |
|
| 39 |
# Truncate the string up to the last period
|
| 40 |
+
truncated_caption = full_sentence[:last_period_index + 1]
|
| 41 |
|
| 42 |
# print(truncated_caption)
|
| 43 |
print(f"\n—\nIMAGE CAPTION: {truncated_caption}")
|