arshan123 commited on
Commit
8e8c718
·
verified ·
1 Parent(s): 3256d79

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +50 -0
Dockerfile ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ # Set up a new user named "user" with user ID 1000 (required by HuggingFace Spaces)
4
+ RUN useradd -m -u 1000 user
5
+
6
+ # Set working directory
7
+ WORKDIR /app
8
+
9
+ # System dependencies for audio processing
10
+ RUN apt-get update && apt-get install -y \
11
+ libsndfile1 \
12
+ ffmpeg \
13
+ libgomp1 \
14
+ && rm -rf /var/lib/apt/lists/*
15
+
16
+ # Copy requirements and install as root
17
+ COPY --chown=user requirements.txt /app/requirements.txt
18
+ RUN pip install --no-cache-dir --upgrade pip && \
19
+ pip install --no-cache-dir -r requirements.txt
20
+
21
+ # Install PyTorch CPU wheels for model downloads/runtime
22
+ RUN pip install --no-cache-dir torch torchaudio --index-url https://download.pytorch.org/whl/cpu
23
+
24
+ # Copy application files with correct ownership
25
+ COPY --chown=user app.py /app/
26
+ COPY --chown=user detector.py /app/
27
+ COPY --chown=user self_learning_train.py /app/
28
+
29
+ # Switch to the "user" user
30
+ USER user
31
+
32
+ # Set home to the user's home directory
33
+ ENV HOME=/home/user \
34
+ PATH=/home/user/.local/bin:$PATH \
35
+ PYTHONUNBUFFERED=1
36
+
37
+ # Pre-download models (will be cached in user's home)
38
+ RUN python -c "from transformers import AutoModelForAudioClassification, AutoFeatureExtractor, WhisperProcessor, WhisperForConditionalGeneration; \
39
+ print('Downloading models...'); \
40
+ AutoModelForAudioClassification.from_pretrained('garystafford/wav2vec2-deepfake-voice-detector'); \
41
+ AutoFeatureExtractor.from_pretrained('garystafford/wav2vec2-deepfake-voice-detector'); \
42
+ WhisperProcessor.from_pretrained('openai/whisper-base'); \
43
+ WhisperForConditionalGeneration.from_pretrained('openai/whisper-base'); \
44
+ print('Models downloaded successfully')"
45
+
46
+ # Expose HuggingFace Spaces port
47
+ EXPOSE 7860
48
+
49
+ # AI_Voice_Detector/Dockerfile (CMD line)
50
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]