Skip to content

Commit

Permalink
Fix for safetensor model detection (#943)
Browse files Browse the repository at this point in the history
  • Loading branch information
raivisdejus authored Oct 12, 2024
1 parent 1baccef commit 724fdea
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions buzz/transformers_whisper.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ def transcribe(
device = "cuda" if torch.cuda.is_available() else "cpu"
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32

safetensors_path = os.path.join(self.model_id, "model.safetensors")
use_safetensors = os.path.exists(safetensors_path)
use_safetensors = True
if os.path.exists(self.model_id):
safetensors_files = [f for f in os.listdir(self.model_id) if f.endswith(".safetensors")]
use_safetensors = len(safetensors_files) > 0

model = AutoModelForSpeechSeq2Seq.from_pretrained(
self.model_id, torch_dtype=torch_dtype, use_safetensors=use_safetensors
Expand Down

0 comments on commit 724fdea

Please sign in to comment.