fffiloni commited on
Commit
5e6dba7
1 Parent(s): c657020

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
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
- print(data)
 
 
 
 
 
 
29
 
30
  # Find the last occurrence of "."
31
- last_period_index = kosmos2_result[1].rfind('.')
32
 
33
  # Truncate the string up to the last period
34
- truncated_caption = kosmos2_result[1][:last_period_index + 1]
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}")