rjzevallos commited on
Commit
3b07c9e
·
1 Parent(s): d860e14

Fix: Use openai-whisper library for model loading instead of torch.hub

Browse files
Files changed (3) hide show
  1. Dockerfile +1 -1
  2. requirements.txt +1 -0
  3. server_wrapper.py +15 -3
Dockerfile CHANGED
@@ -19,7 +19,7 @@ RUN pip install --no-cache-dir -r requirements.txt
19
  COPY . .
20
 
21
  # Pre-descargar el modelo durante la construcción
22
- RUN python -c "import torch; torch.hub.load('openai/whisper', 'large-v3')"
23
 
24
  EXPOSE 7860
25
 
 
19
  COPY . .
20
 
21
  # Pre-descargar el modelo durante la construcción
22
+ RUN python -c "import whisper; whisper.load_model('large-v3')" || echo "Model download skipped, will download at runtime"
23
 
24
  EXPOSE 7860
25
 
requirements.txt CHANGED
@@ -10,3 +10,4 @@ torchaudio>=2.0.0
10
  tqdm
11
  tiktoken
12
  triton>=2.0.0,<3;platform_machine=="x86_64" and sys_platform=="linux" or sys_platform=="linux2"
 
 
10
  tqdm
11
  tiktoken
12
  triton>=2.0.0,<3;platform_machine=="x86_64" and sys_platform=="linux" or sys_platform=="linux2"
13
+ openai-whisper>=20230314
server_wrapper.py CHANGED
@@ -17,13 +17,25 @@ _online = None
17
  def _get_model_path():
18
  """Get the path to the Whisper model. Download if needed."""
19
  import os
20
- model_dir = os.path.expanduser('~/.cache/torch/hub/checkpoints')
 
 
 
 
 
21
  model_path = os.path.join(model_dir, 'large-v3.pt')
22
 
23
  if not os.path.exists(model_path):
24
  print(f"Model not found at {model_path}. Downloading...")
25
- import torch
26
- torch.hub.load('openai/whisper', 'large-v3')
 
 
 
 
 
 
 
27
 
28
  return model_path
29
 
 
17
  def _get_model_path():
18
  """Get the path to the Whisper model. Download if needed."""
19
  import os
20
+ model_dir = os.path.expanduser('~/.cache/whisper')
21
+
22
+ # Create model directory if it doesn't exist
23
+ if not os.path.exists(model_dir):
24
+ os.makedirs(model_dir, exist_ok=True)
25
+
26
  model_path = os.path.join(model_dir, 'large-v3.pt')
27
 
28
  if not os.path.exists(model_path):
29
  print(f"Model not found at {model_path}. Downloading...")
30
+ try:
31
+ import whisper
32
+ whisper.load_model('large-v3')
33
+ print(f"Model downloaded to {model_path}")
34
+ except Exception as e:
35
+ print(f"Warning: Could not download model: {e}")
36
+ # Fallback to trying current directory
37
+ if os.path.exists('./large-v3.pt'):
38
+ return './large-v3.pt'
39
 
40
  return model_path
41