Update app.py
Browse files
app.py
CHANGED
|
@@ -19,9 +19,12 @@ def generate_alt_text(files, max_new_tokens):
|
|
| 19 |
out = captioner(
|
| 20 |
img,
|
| 21 |
generate_kwargs={
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
)
|
| 27 |
caption = out[0]["generated_text"].strip().capitalize()
|
|
|
|
| 19 |
out = captioner(
|
| 20 |
img,
|
| 21 |
generate_kwargs={
|
| 22 |
+
"max_new_tokens": int(max_new_tokens),
|
| 23 |
+
"num_beams": 4, # You can still use num_beams with sampling, it creates diverse beams
|
| 24 |
+
"no_repeat_ngram_size": 2,
|
| 25 |
+
"do_sample": True,
|
| 26 |
+
"temperature": 0.9, # Experiment with this value
|
| 27 |
+
"top_k": 50 # Or top_p=0.95
|
| 28 |
}
|
| 29 |
)
|
| 30 |
caption = out[0]["generated_text"].strip().capitalize()
|