lolout1 commited on
Commit
83b4d0c
·
1 Parent(s): 214f9f9

deploying to hf spaces Docker file changes

Browse files
Files changed (1) hide show
  1. Dockerfile +9 -10
Dockerfile CHANGED
@@ -7,7 +7,6 @@ RUN apt-get update && apt-get install -y \
7
  python3.8 \
8
  python3.8-dev \
9
  python3.8-distutils \
10
- python3-pip \
11
  git \
12
  wget \
13
  curl \
@@ -30,15 +29,15 @@ RUN apt-get update && apt-get install -y \
30
  RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1 && \
31
  update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
32
 
33
- # Install pip for python3.8
34
- RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
35
  python get-pip.py && \
36
  rm get-pip.py
37
 
38
  # Upgrade pip and install build tools
39
  RUN python -m pip install --upgrade pip==23.0.1 setuptools==59.5.0 wheel cython
40
 
41
- # Create user
42
  RUN useradd -m -u 1000 user
43
  USER user
44
  ENV HOME=/home/user \
@@ -63,8 +62,8 @@ RUN pip install --user \
63
  # Install detectron2 for PyTorch 1.9 CPU
64
  RUN pip install --user detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch1.9/index.html
65
 
66
- # Install pycocotools separately with proper build dependencies
67
- RUN pip install --user "git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI"
68
 
69
  # Install other ML dependencies
70
  RUN pip install --user \
@@ -75,7 +74,7 @@ RUN pip install --user \
75
  tqdm==4.64.1 \
76
  imutils==0.5.4
77
 
78
- # Install Gradio and web dependencies
79
  RUN pip install --user \
80
  gradio==3.35.2 \
81
  huggingface_hub==0.11.1 \
@@ -92,14 +91,14 @@ RUN pip install --user \
92
  gdown==4.5.4 \
93
  wget==3.2
94
 
95
- # Try NATTEN for CPU (optional)
96
  RUN pip install --user natten==0.14.6 -f https://shi-labs.com/natten/wheels/cpu/torch1.9/index.html || \
97
  echo "NATTEN installation failed - continuing without it"
98
 
99
  # Copy application files
100
  COPY --chown=user:user . /app
101
 
102
- # Set environment variables
103
  ENV CUDA_VISIBLE_DEVICES=""
104
  ENV FORCE_CUDA="0"
105
  ENV OMP_NUM_THREADS=4
@@ -108,4 +107,4 @@ ENV PYTHONUNBUFFERED=1
108
 
109
  EXPOSE 7860
110
 
111
- CMD ["python", "gradio_test.py"]
 
7
  python3.8 \
8
  python3.8-dev \
9
  python3.8-distutils \
 
10
  git \
11
  wget \
12
  curl \
 
29
  RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1 && \
30
  update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
31
 
32
+ # Install pip for Python 3.8 specifically
33
+ RUN curl https://bootstrap.pypa.io/pip/3.8/get-pip.py -o get-pip.py && \
34
  python get-pip.py && \
35
  rm get-pip.py
36
 
37
  # Upgrade pip and install build tools
38
  RUN python -m pip install --upgrade pip==23.0.1 setuptools==59.5.0 wheel cython
39
 
40
+ # Create user for HF Spaces
41
  RUN useradd -m -u 1000 user
42
  USER user
43
  ENV HOME=/home/user \
 
62
  # Install detectron2 for PyTorch 1.9 CPU
63
  RUN pip install --user detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch1.9/index.html
64
 
65
+ # Install pycocotools with pre-built wheel to avoid compilation issues
66
+ RUN pip install --user pycocotools --no-build-isolation
67
 
68
  # Install other ML dependencies
69
  RUN pip install --user \
 
74
  tqdm==4.64.1 \
75
  imutils==0.5.4
76
 
77
+ # Install Gradio and web dependencies with compatible versions
78
  RUN pip install --user \
79
  gradio==3.35.2 \
80
  huggingface_hub==0.11.1 \
 
91
  gdown==4.5.4 \
92
  wget==3.2
93
 
94
+ # Try NATTEN for CPU (optional - will continue if fails)
95
  RUN pip install --user natten==0.14.6 -f https://shi-labs.com/natten/wheels/cpu/torch1.9/index.html || \
96
  echo "NATTEN installation failed - continuing without it"
97
 
98
  # Copy application files
99
  COPY --chown=user:user . /app
100
 
101
+ # Set environment variables for CPU-only operation
102
  ENV CUDA_VISIBLE_DEVICES=""
103
  ENV FORCE_CUDA="0"
104
  ENV OMP_NUM_THREADS=4
 
107
 
108
  EXPOSE 7860
109
 
110
+ CMD ["python", "app.py"]