File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -85,9 +85,15 @@ def bytes_to_unicode():
85
85
hparams = json .load ((dir_model / "config.json" ).open ("r" , encoding = "utf8" ))
86
86
87
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
-
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
+
91
97
model = WhisperForConditionalGeneration .from_pretrained (dir_model )
92
98
93
99
#code.interact(local=locals())
You can’t perform that action at this time.
0 commit comments