Omnia-cy commited on
Commit
226a010
·
verified ·
1 Parent(s): 95a4fee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
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
- return processor.decode(output[0], skip_special_tokens=True)
 
 
 
 
 
 
 
 
 
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