lolout1 commited on
Commit
214f9f9
·
1 Parent(s): 2100d80

added changes to gradio_test.py for gradio dependency issues

Browse files
Files changed (2) hide show
  1. Dockerfile +64 -78
  2. app.py +14 -4
Dockerfile CHANGED
@@ -4,8 +4,9 @@ ENV DEBIAN_FRONTEND=noninteractive
4
 
5
  # Install system dependencies
6
  RUN apt-get update && apt-get install -y \
7
- python3.9 \
8
- python3.9-dev \
 
9
  python3-pip \
10
  git \
11
  wget \
@@ -25,96 +26,80 @@ RUN apt-get update && apt-get install -y \
25
  ninja-build \
26
  && rm -rf /var/lib/apt/lists/*
27
 
28
- # Set python3.9 as default
29
- RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1 && \
30
- update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
31
 
32
- # Upgrade pip
33
- RUN python -m pip install --upgrade pip==23.0.1 setuptools==65.5.0 wheel
 
 
 
 
 
34
 
35
  # Create user
36
  RUN useradd -m -u 1000 user
 
 
 
 
37
  WORKDIR /app
38
 
39
- # Install PyTorch 1.9 CPU - FIXED VERSION
40
- RUN pip install torch==1.9.0+cpu torchvision==0.10.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
41
 
42
- # Install core dependencies compatible with torch 1.9
43
- RUN pip install \
44
- numpy==1.19.5 \
 
 
45
  Pillow==8.3.2 \
46
- opencv-python==4.5.3.56 \
47
- cython==0.29.24
48
-
49
- # Install detectron2 for PyTorch 1.9 CPU - CORRECT URL
50
- RUN python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch1.9/index.html
51
-
52
- # Install Gradio with compatible dependencies
53
- RUN pip install \
54
- gradio==3.1.7 \
55
- httpx==0.23.0 \
56
- httpcore==0.15.0 \
57
- anyio==3.6.1 \
58
- starlette==0.19.1 \
 
 
 
 
 
 
 
 
 
 
 
59
  fastapi==0.78.0 \
60
  uvicorn==0.18.2
61
 
62
- # Install other dependencies
63
- RUN pip install \
64
- huggingface_hub==0.8.1 \
65
- scipy==1.7.1 \
66
- scikit-image==0.18.3 \
67
- scikit-learn==1.0.2 \
68
- timm==0.4.12 \
69
- einops==0.3.2 \
70
- tqdm==4.62.3 \
71
- imutils==0.5.4 \
72
- shapely==1.8.0 \
73
- h5py==3.1.0 \
74
- regex==2021.11.10 \
75
- ftfy==6.0.3 \
76
- inflect==5.3.0 \
77
- gdown==4.2.0 \
78
- wget==3.2 \
79
  PyYAML==5.4.1 \
80
- pycocotools==2.0.4 \
81
- matplotlib==3.5.1
82
-
83
- # Optional dependencies
84
- RUN pip install submitit==1.4.1 || echo "submitit failed"
85
- RUN pip install pytorch_lightning==1.5.10 || echo "pytorch_lightning failed"
86
- RUN pip install wandb==0.12.9 || echo "wandb failed"
87
- RUN pip install icecream==2.1.1 || echo "icecream failed"
88
-
89
- # Try NATTEN for torch 1.9
90
- RUN pip install natten==0.14.6 -f https://shi-labs.com/natten/wheels/cpu/torch1.9/index.html || \
91
- echo "NATTEN installation failed"
92
-
93
- # OneFormer specific dependencies
94
- RUN pip install \
95
- omegaconf==2.1.1 \
96
- hydra-core==1.1.1 \
97
- termcolor==1.1.0 \
98
- tabulate==0.8.9 \
99
- yacs==0.1.8 \
100
- cloudpickle==2.0.0 \
101
- packaging==21.3
102
-
103
- # Install additional tools
104
- RUN pip install \
105
- iopath==0.1.9 \
106
- fvcore==0.1.5.post20220512 \
107
- pydot==1.4.2 \
108
- portalocker==2.5.1
109
-
110
- # Switch to user
111
- USER user
112
- ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
113
-
114
- # Copy application
115
  COPY --chown=user:user . /app
116
 
117
- # CPU environment
118
  ENV CUDA_VISIBLE_DEVICES=""
119
  ENV FORCE_CUDA="0"
120
  ENV OMP_NUM_THREADS=4
@@ -122,4 +107,5 @@ ENV MKL_NUM_THREADS=4
122
  ENV PYTHONUNBUFFERED=1
123
 
124
  EXPOSE 7860
 
125
  CMD ["python", "gradio_test.py"]
 
4
 
5
  # Install system dependencies
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 \
 
26
  ninja-build \
27
  && rm -rf /var/lib/apt/lists/*
28
 
29
+ # Set python3.8 as default
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 \
45
+ PATH=/home/user/.local/bin:$PATH
46
+
47
  WORKDIR /app
48
 
49
+ # Install PyTorch 1.9 CPU
50
+ RUN pip install --user torch==1.9.0+cpu torchvision==0.10.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
51
 
52
+ # Install numpy first (required for other packages)
53
+ RUN pip install --user numpy==1.21.6
54
+
55
+ # Install core dependencies
56
+ RUN pip install --user \
57
  Pillow==8.3.2 \
58
+ opencv-python==4.5.5.64 \
59
+ scipy==1.7.3 \
60
+ scikit-image==0.19.3 \
61
+ scikit-learn==1.0.2
62
+
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 \
71
+ timm==0.4.12 \
72
+ einops==0.6.1 \
73
+ h5py==3.7.0 \
74
+ shapely==1.8.5 \
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 \
82
  fastapi==0.78.0 \
83
  uvicorn==0.18.2
84
 
85
+ # Install remaining dependencies
86
+ RUN pip install --user \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  PyYAML==5.4.1 \
88
+ matplotlib==3.5.3 \
89
+ regex==2022.10.31 \
90
+ ftfy==6.1.1 \
91
+ inflect==6.0.4 \
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
 
107
  ENV PYTHONUNBUFFERED=1
108
 
109
  EXPOSE 7860
110
+
111
  CMD ["python", "gradio_test.py"]
app.py CHANGED
@@ -35,8 +35,12 @@ def check_dependencies():
35
  logger.info(f"PyTorch version: {torch.__version__}")
36
  logger.info(f"CUDA available: {torch.cuda.is_available()}")
37
 
 
 
 
 
38
  import detectron2
39
- logger.info(f"Detectron2 imported successfully")
40
 
41
  import gradio as gr
42
  logger.info(f"Gradio version: {gr.__version__}")
@@ -56,6 +60,10 @@ def check_dependencies():
56
  PIL.Image.LINEAR = PIL.Image.BILINEAR
57
  logger.info("Applied PIL compatibility patch")
58
 
 
 
 
 
59
  return True
60
 
61
  except ImportError as e:
@@ -65,7 +73,8 @@ def check_dependencies():
65
  def main():
66
  """Main application entry point"""
67
  print("=" * 50)
68
- print(f"Application Startup at {time.strftime('%Y-%m-%d %H:%M:%S')}")
 
69
  print("=" * 50)
70
 
71
  # Setup paths
@@ -87,11 +96,12 @@ def main():
87
  interface.queue(max_size=10).launch(
88
  server_name="0.0.0.0",
89
  server_port=7860,
90
- share=False # Disable share for production
 
91
  )
92
 
93
  except Exception as e:
94
- logger.error(f"Error: {e}")
95
  import traceback
96
  traceback.print_exc()
97
  sys.exit(1)
 
35
  logger.info(f"PyTorch version: {torch.__version__}")
36
  logger.info(f"CUDA available: {torch.cuda.is_available()}")
37
 
38
+ # Verify torch version
39
+ if not torch.__version__.startswith('1.9'):
40
+ logger.warning(f"Expected PyTorch 1.9.x, got {torch.__version__}")
41
+
42
  import detectron2
43
+ logger.info(f"Detectron2 version: {detectron2.__version__}")
44
 
45
  import gradio as gr
46
  logger.info(f"Gradio version: {gr.__version__}")
 
60
  PIL.Image.LINEAR = PIL.Image.BILINEAR
61
  logger.info("Applied PIL compatibility patch")
62
 
63
+ # Check numpy version
64
+ import numpy as np
65
+ logger.info(f"NumPy version: {np.__version__}")
66
+
67
  return True
68
 
69
  except ImportError as e:
 
73
  def main():
74
  """Main application entry point"""
75
  print("=" * 50)
76
+ print(f"NeuroNest Application Startup")
77
+ print(f"Time: {time.strftime('%Y-%m-%d %H:%M:%S')}")
78
  print("=" * 50)
79
 
80
  # Setup paths
 
96
  interface.queue(max_size=10).launch(
97
  server_name="0.0.0.0",
98
  server_port=7860,
99
+ share=True,
100
+ debug=False
101
  )
102
 
103
  except Exception as e:
104
+ logger.error(f"Error launching app: {e}")
105
  import traceback
106
  traceback.print_exc()
107
  sys.exit(1)