mic3333 commited on
Commit
9711b92
·
1 Parent(s): 64b05cb

Fix: Resolve cache permission errors in Docker

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -1
  2. app.py +3 -1
Dockerfile CHANGED
@@ -25,7 +25,7 @@ RUN pip install --no-cache-dir -r /code/requirements.txt
25
 
26
  # Pre-download the models at build time to avoid runtime delays.
27
  # This ensures the application starts up quickly in the Space.
28
- RUN python -c "from transformers import pipeline; import whisper; pipeline('summarization', model='facebook/bart-large-cnn'); whisper.load_model('base')"
29
 
30
  # Copy the rest of the application code into the container
31
  COPY . /code/
 
25
 
26
  # Pre-download the models at build time to avoid runtime delays.
27
  # This ensures the application starts up quickly in the Space.
28
+ RUN python -c "from transformers import pipeline; import whisper; pipeline('summarization', model='facebook/bart-large-cnn'); whisper.load_model('base', download_root='/code/cache')"
29
 
30
  # Copy the rest of the application code into the container
31
  COPY . /code/
app.py CHANGED
@@ -11,7 +11,9 @@ import numpy as np
11
  class TextSummarizer:
12
  def __init__(self):
13
  self.summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
14
- self.whisper_model = whisper.load_model("base")
 
 
15
 
16
  def extract_text_from_pdf(self, pdf_file):
17
  """Extract text from a PDF file object"""
 
11
  class TextSummarizer:
12
  def __init__(self):
13
  self.summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
14
+ # Ensure whisper uses a writable cache directory
15
+ cache_dir = "/code/cache"
16
+ self.whisper_model = whisper.load_model("base", download_root=cache_dir)
17
 
18
  def extract_text_from_pdf(self, pdf_file):
19
  """Extract text from a PDF file object"""