Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- 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 |
-
#
|
| 33 |
-
RUN
|
| 34 |
-
|
| 35 |
-
import
|
| 36 |
-
import
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
print(
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
print('
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 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
|