ybelkada HF staff commited on
Commit
1818f9e
1 Parent(s): 77a8b29

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -0
app.py CHANGED
@@ -22,6 +22,11 @@ def inference(raw_image, question, decoding_strategy):
22
  inputs["do_sample"] = True
23
  inputs["top_k"] = 50
24
  inputs["top_p"] = 0.95
 
 
 
 
 
25
 
26
  out = model_image_captioning.generate(**inputs)
27
  return processor.batch_decode(out, skip_special_tokens=True)[0]
22
  inputs["do_sample"] = True
23
  inputs["top_k"] = 50
24
  inputs["top_p"] = 0.95
25
+ elif decoding_strategy == "Contrastive search":
26
+ inputs["penalty_alpha"] = 0.6
27
+ inputs["top_k"] = 4
28
+ inputs["max_length"] = 512
29
+
30
 
31
  out = model_image_captioning.generate(**inputs)
32
  return processor.batch_decode(out, skip_special_tokens=True)[0]