lolout1 commited on
Commit
3387ba6
·
1 Parent(s): 88f4880

updating dockerfile and dependencies

Browse files
Files changed (3) hide show
  1. CLAUDE.md +0 -76
  2. Dockerfile +6 -12
  3. requirements.txt +5 -9
CLAUDE.md DELETED
@@ -1,76 +0,0 @@
1
- # CLAUDE.md
2
-
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
- ## Project Overview
6
- This is a OneFormer-based universal image segmentation application with integrated contrast detection capabilities. It supports panoptic, instance, and semantic segmentation using transformer-based models (Swin-L and DiNAT-L backbones).
7
-
8
- ## Essential Commands
9
-
10
- ### Setup and Installation
11
- ```bash
12
- # Download model checkpoints from HuggingFace
13
- python setup.py --download
14
-
15
- # Build deformable attention CUDA operations (required)
16
- bash deform_setup.sh
17
-
18
- # Install NATTEN if needed
19
- cd NATTEN && pip install -e .
20
- ```
21
-
22
- ### Running the Application
23
- ```bash
24
- # Main application launcher
25
- bash t.sh
26
-
27
- # Or run directly
28
- python gradio_test.py
29
- ```
30
-
31
- ### Testing
32
- ```bash
33
- # Run NATTEN tests
34
- cd NATTEN && python -m unittest discover -v -s ./tests
35
- ```
36
-
37
- ## Architecture Overview
38
-
39
- ### Core Components
40
- 1. **OneFormer Model** (`oneformer/`): Universal segmentation transformer implementation
41
- - `oneformer_model.py`: Main model class
42
- - `modeling/`: Model components including backbones, decoders, and criterion
43
- - `data/`: Dataset mappers and tokenizers for text queries
44
-
45
- 2. **Gradio Applications** (multiple entry points):
46
- - `gradio_test.py`: Main combined interface with pre/post-processing logic
47
- - `gradio_app.py`: Basic segmentation interface
48
- - `gradio_contrast.py`: Contrast detection focused interface
49
-
50
- 3. **Contrast Detection** (`utils/`): Multiple contrast analysis algorithms
51
- - `improved_contrast_analyzer.py`: Main analyzer combining all methods
52
- - Individual analyzers: luminance, saturation, hue contrast detection
53
-
54
- 4. **Model Configurations** (`configs/`): Pre-defined configs for:
55
- - ADE20K (150 classes)
56
- - Cityscapes (19 classes)
57
- - COCO (133 classes)
58
-
59
- ### Key Implementation Details
60
- - Models are loaded from HuggingFace hub (shi-labs organization)
61
- - Supports both CPU and GPU inference (auto-detection)
62
- - Custom CUDA kernels for multi-scale deformable attention
63
- - NATTEN library provides neighborhood attention operations
64
-
65
- ### Model Checkpoints
66
- The application uses pre-trained models from:
67
- - `shi-labs/oneformer_cityscapes_swin_large`
68
- - `shi-labs/oneformer_coco_swin_large`
69
- - `shi-labs/oneformer_ade20k_swin_large`
70
- - DiNAT variants also available
71
-
72
- ### Important Notes
73
- - Always run `deform_setup.sh` after environment setup for CUDA operations
74
- - The application expects model checkpoints to be downloaded before running
75
- - Gradio interface runs on port 7860 by default
76
- - GPU memory requirements vary by model (Swin-L models need ~12GB)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Dockerfile CHANGED
@@ -23,16 +23,12 @@ RUN apt-get update && apt-get install -y \
23
  # Create user
24
  RUN useradd -m -u 1000 user
25
 
26
- # Install specific PyTorch CPU version FIRST
27
- RUN pip install torch==2.0.1+cpu torchvision==0.15.2+cpu torchaudio==2.0.2+cpu --index-url https://download.pytorch.org/whl/cpu --no-deps
28
- RUN pip install numpy pillow typing-extensions
29
 
30
- # Install detectron2
31
- RUN git clone https://github.com/facebookresearch/detectron2 /tmp/detectron2 && \
32
- cd /tmp/detectron2 && \
33
- git checkout v0.6 && \
34
- pip install -e . --no-deps && \
35
- pip install -r requirements.txt
36
 
37
  # Switch to user
38
  USER user
@@ -45,13 +41,11 @@ ENV FORCE_CUDA="0"
45
  ENV TORCH_CUDA_ARCH_LIST=""
46
 
47
  # Copy and install requirements
 
48
  RUN pip install --user --no-cache-dir -r requirements.txt
49
 
50
  # Copy app files
51
  COPY --chown=user:user . .
52
 
53
- # Install NATTEN last to ensure correct torch version
54
- RUN pip install --user natten==0.14.6+torch200cpu -f https://shi-labs.com/natten/wheels/cpu/torch2.0.0/index.html --no-deps
55
-
56
  EXPOSE 7860
57
  CMD ["python", "app.py"]
 
23
  # Create user
24
  RUN useradd -m -u 1000 user
25
 
26
+ # Install PyTorch with ALL dependencies
27
+ RUN pip install torch==2.0.1+cpu torchvision==0.15.2+cpu torchaudio==2.0.2+cpu \
28
+ --index-url https://download.pytorch.org/whl/cpu
29
 
30
+ # Install detectron2 using pre-built wheel (much more reliable)
31
+ RUN pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch2.0/index.html
 
 
 
 
32
 
33
  # Switch to user
34
  USER user
 
41
  ENV TORCH_CUDA_ARCH_LIST=""
42
 
43
  # Copy and install requirements
44
+ COPY --chown=user:user requirements.txt .
45
  RUN pip install --user --no-cache-dir -r requirements.txt
46
 
47
  # Copy app files
48
  COPY --chown=user:user . .
49
 
 
 
 
50
  EXPOSE 7860
51
  CMD ["python", "app.py"]
requirements.txt CHANGED
@@ -1,8 +1,5 @@
1
-
2
-
3
-
4
- # Rest of your dependencies
5
- numpy>=1.23.0
6
  Pillow>=8.3.2
7
  opencv-python
8
  git+https://github.com/cocodataset/panopticapi.git
@@ -25,11 +22,10 @@ inflect
25
  diffdist
26
  gdown
27
  huggingface_hub
28
- pytorch_lightning
29
  tqdm
30
  gradio
31
  wget
32
 
33
- # NATTEN
34
- -f https://shi-labs.com/natten/wheels/cpu/torch2.0.0/index.html
35
- natten==0.14.6
 
1
+ # Core dependencies (NO torch, NO detectron2, NO natten)
2
+ numpy>=1.23.0,<2.0.0
 
 
 
3
  Pillow>=8.3.2
4
  opencv-python
5
  git+https://github.com/cocodataset/panopticapi.git
 
22
  diffdist
23
  gdown
24
  huggingface_hub
25
+ pytorch_lightning==2.0.0
26
  tqdm
27
  gradio
28
  wget
29
 
30
+ # NATTEN - install separately if needed
31
+ # natten==0.14.6+torch200cpu -f https://shi-labs.com/natten/wheels/cpu/torch2.0.0/index.html