Spaces:
Running
Running
Update app.py
Browse files
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
|
19 |
def load_model():
|
20 |
-
print("Loading
|
21 |
-
processor = WhisperProcessor.from_pretrained("
|
22 |
-
model = WhisperForConditionalGeneration.from_pretrained("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|