Spaces:
Running
Running
Anders Bjarby
commited on
convert : update convert-h5-to-ggml.py (#2840)
Browse files
models/convert-h5-to-ggml.py
CHANGED
|
@@ -85,9 +85,15 @@ encoder_added = json.load((dir_model / "added_tokens.json").open( "r", encoding=
|
|
| 85 |
hparams = json.load((dir_model / "config.json").open("r", encoding="utf8"))
|
| 86 |
|
| 87 |
# Add this block to handle missing 'max_length'
|
| 88 |
-
if "max_length" not in hparams:
|
| 89 |
-
hparams["max_length"] = hparams.get("max_target_positions", 448)
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
model = WhisperForConditionalGeneration.from_pretrained(dir_model)
|
| 92 |
|
| 93 |
#code.interact(local=locals())
|
|
|
|
| 85 |
hparams = json.load((dir_model / "config.json").open("r", encoding="utf8"))
|
| 86 |
|
| 87 |
# Add this block to handle missing 'max_length'
|
| 88 |
+
if "max_length" not in hparams or hparams["max_length"] is None:
|
| 89 |
+
hparams["max_length"] = hparams.get("max_target_positions", 448) # Default to 448 if missing
|
| 90 |
+
elif not isinstance(hparams["max_length"], int):
|
| 91 |
+
try:
|
| 92 |
+
hparams["max_length"] = int(hparams["max_length"]) # Convert if necessary
|
| 93 |
+
except ValueError:
|
| 94 |
+
print(f"Warning: Invalid max_length value '{hparams['max_length']}', using default 448.")
|
| 95 |
+
hparams["max_length"] = 448
|
| 96 |
+
|
| 97 |
model = WhisperForConditionalGeneration.from_pretrained(dir_model)
|
| 98 |
|
| 99 |
#code.interact(local=locals())
|