fffiloni commited on
Commit
a15b3ce
1 Parent(s): a2c4d07

Clean caption if truncated

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -11,8 +11,17 @@ def get_caption(image_in):
11
  True, # bool in 'Enable detailed captioning' Checkbox component
12
  fn_index=2
13
  )
14
- print(f"IMAGE CAPTION: {fuyu_result}")
15
- return fuyu_result
 
 
 
 
 
 
 
 
 
16
 
17
  import re
18
  import torch
 
11
  True, # bool in 'Enable detailed captioning' Checkbox component
12
  fn_index=2
13
  )
14
+
15
+ # Find the last occurrence of "."
16
+ last_period_index = fuyu_result.rfind('.')
17
+
18
+ # Truncate the string up to the last period
19
+ truncated_caption = fuyu_result[:last_period_index + 1]
20
+
21
+ # print(truncated_caption)
22
+ print(f"IMAGE CAPTION: {truncated_caption}")
23
+
24
+ return truncated_caption
25
 
26
  import re
27
  import torch