Anders Bjarby commited on
Commit
3d457ce
·
unverified ·
1 Parent(s): 749d15b

convert : update convert-h5-to-ggml.py (#2840)

Browse files
Files changed (1) hide show
  1. models/convert-h5-to-ggml.py +9 -3
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())