lolout1 commited on
Commit
8e3ed2a
·
1 Parent(s): 87b30f4

Adding changes to requirements.txt and Dockerfile

Browse files
Files changed (2) hide show
  1. Dockerfile +45 -13
  2. requirements.txt +18 -33
Dockerfile CHANGED
@@ -1,27 +1,59 @@
1
  FROM python:3.10
2
 
3
- WORKDIR /app
 
 
 
 
4
 
5
- # Install system dependencies
 
 
 
 
 
6
  RUN apt-get update && apt-get install -y \
7
  git \
8
  build-essential \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
- # Install torch CPU version first
12
- RUN pip install torch==2.0.1+cpu torchvision==0.15.2+cpu torchaudio==2.0.2+cpu \
13
- --extra-index-url https://download.pytorch.org/whl/cpu
14
 
15
- # Clone and install detectron2
16
- RUN git clone https://github.com/facebookresearch/detectron2 && \
17
- pip install -e detectron2
18
 
19
- # Copy requirements and install
20
- COPY requirements.txt .
21
- RUN pip install -r requirements.txt
 
 
 
 
 
22
 
23
  # Copy app files
24
- COPY . .
 
 
 
25
 
26
- # Run the app
27
  CMD ["python", "app.py"]
 
1
  FROM python:3.10
2
 
3
+ # Set up user to avoid permission issues
4
+ RUN useradd -m -u 1000 user
5
+ USER user
6
+ ENV HOME=/home/user \
7
+ PATH=/home/user/.local/bin:$PATH
8
 
9
+ WORKDIR $HOME/app
10
+
11
+ # Switch to root to install system packages
12
+ USER root
13
+
14
+ # Install ALL necessary system dependencies for OpenCV and GUI libraries
15
  RUN apt-get update && apt-get install -y \
16
  git \
17
  build-essential \
18
+ cmake \
19
+ python3-dev \
20
+ # OpenCV dependencies
21
+ libglib2.0-0 \
22
+ libsm6 \
23
+ libxext6 \
24
+ libxrender-dev \
25
+ libgomp1 \
26
+ libglib2.0-0 \
27
+ libgl1-mesa-glx \
28
+ libglib2.0-0 \
29
+ libgtk2.0-dev \
30
+ # Additional useful libraries
31
+ wget \
32
+ unzip \
33
+ ffmpeg \
34
+ libopencv-dev \
35
  && rm -rf /var/lib/apt/lists/*
36
 
37
+ # Switch back to user
38
+ USER user
 
39
 
40
+ # Copy requirements first (for better caching)
41
+ COPY --chown=user:user requirements.txt .
 
42
 
43
+ # Install Python dependencies
44
+ RUN pip install --user --no-cache-dir --upgrade pip && \
45
+ pip install --user --no-cache-dir torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cpu && \
46
+ pip install --user --no-cache-dir -r requirements.txt
47
+
48
+ # Install detectron2 separately after torch is installed
49
+ RUN git clone https://github.com/facebookresearch/detectron2 $HOME/app/detectron2 && \
50
+ pip install --user -e $HOME/app/detectron2
51
 
52
  # Copy app files
53
+ COPY --chown=user:user . .
54
+
55
+ # Expose port for Gradio
56
+ EXPOSE 7860
57
 
58
+ # Run the application
59
  CMD ["python", "app.py"]
requirements.txt CHANGED
@@ -1,37 +1,22 @@
 
 
1
 
2
- # Core dependencies - PyTorch first
3
-
4
- # CRITICAL: Use pre-built detectron2 wheel for torch 2.0 CPU
5
-
6
- # Rest of your dependencies
7
- numpy>=1.23.0
8
- Pillow>=8.3.2
9
- opencv-python
10
- git+https://github.com/cocodataset/panopticapi.git
11
- git+https://github.com/mcordts/cityscapesScripts.git
12
- imutils
13
- cython
14
- setuptools==59.5.0
15
  scipy
16
- shapely
17
- h5py
18
- submitit
19
- scikit-image
20
- timm==0.4.12
21
  einops
22
- icecream
23
- wandb
24
- ftfy
25
- regex
26
- inflect
27
- diffdist
28
- gdown
29
- huggingface_hub
30
- pytorch_lightning
31
- tqdm
32
- gradio
33
- wget
34
 
35
- # NATTEN should be installed last
36
- -f https://shi-labs.com/natten/wheels/cpu/torch2.0.0/index.html
37
- natten==0.14.6
 
 
 
 
 
 
 
1
+ # Don't include torch/torchvision/torchaudio here since they're in Dockerfile
2
+ # Don't include detectron2 since it's installed separately in Dockerfile
3
 
4
+ # Core dependencies
5
+ gradio==4.19.2
6
+ numpy
7
+ opencv-python-headless==4.8.1.78 # Use headless version for Docker
8
+ pillow
9
+ matplotlib
 
 
 
 
 
 
 
10
  scipy
11
+ timm
 
 
 
 
12
  einops
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
+ # natten with correct torch version
15
+ natten==0.14.6+torch200cpu -f https://shi-labs.com/natten/wheels/cpu/torch2.0.0/index.html
16
+
17
+ # Additional dependencies
18
+ diffdist
19
+ pytest
20
+ ftfy
21
+ iopath
22
+ pycocotools