Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -61,7 +61,16 @@ def get_caption(image):
|
|
| 61 |
with torch.no_grad():
|
| 62 |
output = model.generate(**inputs, max_new_tokens=200)
|
| 63 |
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
# =====================
|
| 67 |
# MAIN PIPELINE
|
|
|
|
| 61 |
with torch.no_grad():
|
| 62 |
output = model.generate(**inputs, max_new_tokens=200)
|
| 63 |
|
| 64 |
+
decoded = processor.decode(output[0], skip_special_tokens=True)
|
| 65 |
+
|
| 66 |
+
# ================= CLEANING STEP =================
|
| 67 |
+
if "ASSISTANT:" in decoded:
|
| 68 |
+
decoded = decoded.split("ASSISTANT:")[-1]
|
| 69 |
+
|
| 70 |
+
if "USER:" in decoded:
|
| 71 |
+
decoded = decoded.split("USER:")[-1]
|
| 72 |
+
|
| 73 |
+
return decoded.strip()
|
| 74 |
|
| 75 |
# =====================
|
| 76 |
# MAIN PIPELINE
|