danielle2035 commited on
Commit
ae5c587
·
1 Parent(s): 0bb7559

fix: pre-download YOLO model during build

Browse files
Files changed (1) hide show
  1. Dockerfile +3 -8
Dockerfile CHANGED
@@ -1,6 +1,5 @@
1
  FROM python:3.10-slim
2
 
3
- # Install system dependencies (OpenCV, ffmpeg, libGL)
4
  RUN apt-get update && apt-get install -y \
5
  libgl1 \
6
  libglib2.0-0 \
@@ -8,27 +7,23 @@ RUN apt-get update && apt-get install -y \
8
  libxext6 \
9
  libxrender-dev \
10
  ffmpeg \
11
- libopencv-dev \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
  WORKDIR /app
15
 
16
- # Copy requirements first for layer caching
17
  COPY requirements.txt .
18
-
19
  RUN pip install --no-cache-dir -r requirements.txt
20
 
21
- # Copy app source
 
 
22
  COPY app.py .
23
  COPY static/ ./static/
24
  COPY templates/ ./templates/
25
 
26
- # Create required directories
27
  RUN mkdir -p models uploads outputs logs
28
 
29
- # HuggingFace Spaces expose port 7860
30
  ENV PORT=7860
31
  EXPOSE 7860
32
 
33
- # Start Flask on port 7860
34
  CMD ["python", "app.py"]
 
1
  FROM python:3.10-slim
2
 
 
3
  RUN apt-get update && apt-get install -y \
4
  libgl1 \
5
  libglib2.0-0 \
 
7
  libxext6 \
8
  libxrender-dev \
9
  ffmpeg \
 
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
  WORKDIR /app
13
 
 
14
  COPY requirements.txt .
 
15
  RUN pip install --no-cache-dir -r requirements.txt
16
 
17
+ # Pré-télécharger le modèle YOLO pendant le build
18
+ RUN python -c "from ultralytics import YOLO; YOLO('yolo11n.pt')"
19
+
20
  COPY app.py .
21
  COPY static/ ./static/
22
  COPY templates/ ./templates/
23
 
 
24
  RUN mkdir -p models uploads outputs logs
25
 
 
26
  ENV PORT=7860
27
  EXPOSE 7860
28
 
 
29
  CMD ["python", "app.py"]