vivek12coder commited on
Commit
c6ecab7
·
1 Parent(s): 056b79f

Fix OpenCV headless: pin version, remove GUI deps, fix matplotlib cache

Browse files
Files changed (2) hide show
  1. Dockerfile +5 -6
  2. requirements.txt +1 -1
Dockerfile CHANGED
@@ -10,17 +10,15 @@ WORKDIR /app
10
  ENV PYTHONPATH="/app"
11
  ENV PYTHONDONTWRITEBYTECODE=1
12
  ENV PYTHONUNBUFFERED=1
13
- ENV MPLCONFIGDIR=/tmp/matplotlib
14
  ENV QT_QPA_PLATFORM=offscreen
 
 
15
 
16
  # Install minimal system dependencies for headless OpenCV
17
  RUN apt-get update && apt-get install -y \
18
  libglib2.0-0 \
19
- libsm6 \
20
- libxext6 \
21
- libxrender1 \
22
  libgomp1 \
23
- libglib2.0-0 \
24
  curl \
25
  && rm -rf /var/lib/apt/lists/*
26
 
@@ -39,7 +37,8 @@ COPY knowledge_base/ ./knowledge_base/
39
  COPY test_leaf_sample.jpg .
40
 
41
  # Create necessary directories
42
- RUN mkdir -p outputs temp /tmp/matplotlib
 
43
 
44
  # Expose the port FastAPI runs on
45
  EXPOSE 7860
 
10
  ENV PYTHONPATH="/app"
11
  ENV PYTHONDONTWRITEBYTECODE=1
12
  ENV PYTHONUNBUFFERED=1
13
+ ENV MPLCONFIGDIR=/app/matplotlib_cache
14
  ENV QT_QPA_PLATFORM=offscreen
15
+ ENV OPENCV_IO_ENABLE_JASPER=0
16
+ ENV OPENCV_IO_ENABLE_OPENEXR=0
17
 
18
  # Install minimal system dependencies for headless OpenCV
19
  RUN apt-get update && apt-get install -y \
20
  libglib2.0-0 \
 
 
 
21
  libgomp1 \
 
22
  curl \
23
  && rm -rf /var/lib/apt/lists/*
24
 
 
37
  COPY test_leaf_sample.jpg .
38
 
39
  # Create necessary directories
40
+ RUN mkdir -p outputs temp /app/matplotlib_cache && \
41
+ chmod 777 /app/matplotlib_cache
42
 
43
  # Expose the port FastAPI runs on
44
  EXPOSE 7860
requirements.txt CHANGED
@@ -11,7 +11,7 @@ uvicorn[standard]
11
  python-multipart
12
  # Image processing
13
  Pillow
14
- opencv-python-headless
15
  # Grad-CAM visualization
16
  grad-cam
17
 
 
11
  python-multipart
12
  # Image processing
13
  Pillow
14
+ opencv-python-headless==4.8.1.78
15
  # Grad-CAM visualization
16
  grad-cam
17