NitinBot001 commited on
Commit
3d1ea91
·
verified ·
1 Parent(s): c25dd77

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +30 -27
Dockerfile CHANGED
@@ -29,38 +29,41 @@ COPY requirements.txt .
29
  # Install Python dependencies
30
  RUN pip install --no-cache-dir -r requirements.txt
31
 
32
- # Create a temporary script for model downloads
33
- RUN echo "import torch; \
34
- from transformers import AutoProcessor, BarkModel; \
35
- import whisper; \
36
- import os; \
37
- print('Downloading Bark model...'); \
38
- try: \
39
- processor = AutoProcessor.from_pretrained('suno/bark-small'); \
40
- model = BarkModel.from_pretrained('suno/bark-small'); \
41
- print('Bark model downloaded successfully'); \
42
- except Exception as e: \
43
- print(f'Error downloading Bark model: {e}'); \
44
- print('Downloading Whisper model...'); \
45
- try: \
46
- whisper_model = whisper.load_model('base'); \
47
- print('Whisper model downloaded successfully'); \
48
- except Exception as e: \
49
- print(f'Error downloading Whisper model: {e}'); \
50
- print('Model download complete!')" > download_models.py && \
51
- python download_models.py && \
52
- rm download_models.py
 
 
 
 
 
 
53
 
54
  # Copy application files
55
  COPY app.py .
56
- COPY README.md .
57
 
58
  # Create directories for temporary files and model cache
59
- RUN mkdir -p /tmp/gradio_cache
60
- RUN mkdir -p /app/temp_audio
61
-
62
- # Set permissions
63
- RUN chmod -R 755 /app
64
 
65
  # Expose the port that Gradio will run on
66
  EXPOSE 7860
 
29
  # Install Python dependencies
30
  RUN pip install --no-cache-dir -r requirements.txt
31
 
32
+ # Download models using heredoc for cleaner syntax
33
+ RUN cat << 'EOF' > download_models.py
34
+ import torch
35
+ from transformers import AutoProcessor, BarkModel
36
+ import whisper
37
+ import os
38
+
39
+ print('Downloading Bark model...')
40
+ try:
41
+ processor = AutoProcessor.from_pretrained('suno/bark-small')
42
+ model = BarkModel.from_pretrained('suno/bark-small')
43
+ print('Bark model downloaded successfully')
44
+ except Exception as e:
45
+ print(f'Error downloading Bark model: {e}')
46
+
47
+ print('Downloading Whisper model...')
48
+ try:
49
+ whisper_model = whisper.load_model('base')
50
+ print('Whisper model downloaded successfully')
51
+ except Exception as e:
52
+ print(f'Error downloading Whisper model: {e}')
53
+
54
+ print('Model download complete!')
55
+ EOF
56
+
57
+ # Run the model download script and clean up
58
+ RUN python download_models.py && rm download_models.py
59
 
60
  # Copy application files
61
  COPY app.py .
 
62
 
63
  # Create directories for temporary files and model cache
64
+ RUN mkdir -p /tmp/gradio_cache && \
65
+ mkdir -p /app/temp_audio && \
66
+ chmod -R 755 /app
 
 
67
 
68
  # Expose the port that Gradio will run on
69
  EXPOSE 7860