Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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]
|