cigol123 commited on
Commit
54026e9
·
verified ·
1 Parent(s): 101a8c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -15,11 +15,19 @@ os.environ["TORCH_HOME"] = cache_dir # Set PyTorch cache directory
15
  # Ensure the cache directory exists and is writable
16
  os.makedirs(cache_dir, exist_ok=True)
17
 
18
- # Load the fine-tuned Macedonian-ASR Whisper model and processor
19
  def load_model():
20
- print("Loading fine-tuned Macedonian-ASR Whisper model and processor...")
21
- processor = WhisperProcessor.from_pretrained("Macedonian-ASR/whisper-large-v3-macedonian-asr")
22
- model = WhisperForConditionalGeneration.from_pretrained("Macedonian-ASR/whisper-large-v3-macedonian-asr")
 
 
 
 
 
 
 
 
23
  print("✓ Model and processor loaded successfully!")
24
  return processor, model
25
 
 
15
  # Ensure the cache directory exists and is writable
16
  os.makedirs(cache_dir, exist_ok=True)
17
 
18
+ # Load the base Whisper model and processor
19
  def load_model():
20
+ print("Loading base Whisper model and processor...")
21
+ processor = WhisperProcessor.from_pretrained("openai/whisper-large-v3")
22
+ model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-large-v3")
23
+
24
+ # Load the fine-tuned weights from the Macedonian-ASR repository
25
+ print("Loading fine-tuned weights from Macedonian-ASR...")
26
+ model.load_state_dict(torch.hub.load_state_dict_from_url(
27
+ "https://huggingface.co/Macedonian-ASR/whisper-large-v3-macedonian-asr/resolve/main/pytorch_model.bin",
28
+ map_location="cpu",
29
+ model_dir=cache_dir # Save downloaded weights to the writable cache directory
30
+ ))
31
  print("✓ Model and processor loaded successfully!")
32
  return processor, model
33