Clean caption if truncated
Browse files
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 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|