MogensR commited on
Commit
6cc2f75
Β·
1 Parent(s): 87680ff

USA SUCKS BIG TIME

Browse files
VideoBackgroundReplacer2/Dockerfile CHANGED
@@ -1,6 +1,6 @@
1
  # ===============================
2
  # Hugging Face Space β€” Stable Dockerfile
3
- # CUDA 12.1.1 + PyTorch 2.5.1 (cu121) + Gradio 4.41.3
4
  # SAM2 installed from source; MatAnyone via pip (repo)
5
  # ===============================
6
 
@@ -20,7 +20,9 @@ ENV DEBIAN_FRONTEND=noninteractive \
20
  NUMEXPR_NUM_THREADS=1 \
21
  HF_HOME=/home/user/app/.hf \
22
  TORCH_HOME=/home/user/app/.torch \
23
- GRADIO_SERVER_PORT=7860
 
 
24
 
25
  # ---- Non-root user ----
26
  RUN useradd -m -u 1000 user
@@ -34,7 +36,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
34
  build-essential gcc g++ pkg-config \
35
  libffi-dev libssl-dev libc6-dev \
36
  libgl1-mesa-glx libglib2.0-0 libsm6 libxext6 libxrender1 libgomp1 \
37
- && rm -rf /var/lib/apt/lists/*
38
 
39
  # ---- Python bootstrap ----
40
  RUN python3 -m pip install --upgrade pip setuptools wheel
@@ -42,17 +44,11 @@ RUN python3 -m pip install --upgrade pip setuptools wheel
42
  # ---- Install PyTorch (CUDA 12.1 wheels) ----
43
  RUN python3 -m pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cu121 \
44
  torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 \
45
- && python3 - <<'PY'
46
  import torch
47
  print("PyTorch:", torch.__version__)
48
  print("CUDA available:", torch.cuda.is_available())
49
  print("torch.version.cuda:", getattr(torch.version, "cuda", None))
50
- try:
51
- import torchaudio, torchvision
52
- print("torchaudio:", torchaudio.__version__)
53
- import torchvision as tv; print("torchvision:", tv.__version__)
54
- except Exception as e:
55
- print("aux libs check:", e)
56
  PY
57
 
58
  # ---- Copy deps first (better caching) ----
@@ -92,19 +88,20 @@ RUN mkdir -p /home/user/app/checkpoints /home/user/app/.hf /home/user/app/.torch
92
  chmod -R 755 /home/user/app && \
93
  find /home/user/app -type d -exec chmod 755 {} \; && \
94
  find /home/user/app -type f -exec chmod 644 {} \; && \
95
- chmod +x /home/user/app/ui.py || true
96
 
97
- # ---- Healthcheck (use exec-form, no heredoc) ----
98
  HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD \
99
  ["python3","-c","import torch; print('torch', torch.__version__, '| cuda', getattr(torch.version,'cuda',None), '| ok=', torch.cuda.is_available())"]
100
 
101
  # ---- Runtime ----
102
  USER user
103
- EXPOSE 7860
104
 
 
105
  CMD ["sh", "-c", "\
106
  echo '===========================================' && \
107
- echo '=== BACKGROUNDFX PRO CONTAINER STARTUP ===' && \
108
  echo '===========================================' && \
109
  echo 'Timestamp:' $(date) && \
110
  echo 'Current directory:' $(pwd) && \
@@ -115,23 +112,22 @@ CMD ["sh", "-c", "\
115
  echo 'Files in app directory:' && \
116
  ls -la && \
117
  echo '' && \
118
- echo '=== UI.PY VERIFICATION ===' && \
119
- if [ -f ui.py ]; then \
120
- echo 'βœ… ui.py found' && \
121
- echo 'File size:' $(wc -c < ui.py) 'bytes' && \
122
- echo 'File permissions:' $(ls -l ui.py) && \
123
  echo 'Testing Python imports...' && \
124
- python3 -B -c 'import gradio; print(\"βœ… Gradio:\", gradio.__version__)' && \
125
  python3 -B -c 'import torch; print(\"βœ… Torch:\", torch.__version__)' && \
126
- echo 'Testing ui.py import...' && \
127
- python3 -B -c 'import sys; sys.path.insert(0, \".\"); import ui; print(\"βœ… ui.py imports successfully\")' && \
128
  echo 'βœ… All checks passed!'; \
129
  else \
130
- echo '❌ ERROR: ui.py not found!' && \
131
  exit 1; \
132
  fi && \
133
  echo '' && \
134
- echo '=== STARTING APPLICATION ===' && \
135
- echo 'Launching ui.py with bytecode disabled...' && \
136
- python3 -B -u ui.py \
137
- "]
 
1
  # ===============================
2
  # Hugging Face Space β€” Stable Dockerfile
3
+ # CUDA 12.1.1 + PyTorch 2.5.1 (cu121) + Streamlit 1.32.0
4
  # SAM2 installed from source; MatAnyone via pip (repo)
5
  # ===============================
6
 
 
20
  NUMEXPR_NUM_THREADS=1 \
21
  HF_HOME=/home/user/app/.hf \
22
  TORCH_HOME=/home/user/app/.torch \
23
+ STREAMLIT_SERVER_PORT=8501 \
24
+ STREAMLIT_SERVER_HEADLESS=true \
25
+ STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
26
 
27
  # ---- Non-root user ----
28
  RUN useradd -m -u 1000 user
 
36
  build-essential gcc g++ pkg-config \
37
  libffi-dev libssl-dev libc6-dev \
38
  libgl1-mesa-glx libglib2.0-0 libsm6 libxext6 libxrender1 libgomp1 \
39
+ && rm -rf /var/lib/apt/lists/*
40
 
41
  # ---- Python bootstrap ----
42
  RUN python3 -m pip install --upgrade pip setuptools wheel
 
44
  # ---- Install PyTorch (CUDA 12.1 wheels) ----
45
  RUN python3 -m pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cu121 \
46
  torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 \
47
+ && python3 - <<'PY'
48
  import torch
49
  print("PyTorch:", torch.__version__)
50
  print("CUDA available:", torch.cuda.is_available())
51
  print("torch.version.cuda:", getattr(torch.version, "cuda", None))
 
 
 
 
 
 
52
  PY
53
 
54
  # ---- Copy deps first (better caching) ----
 
88
  chmod -R 755 /home/user/app && \
89
  find /home/user/app -type d -exec chmod 755 {} \; && \
90
  find /home/user/app -type f -exec chmod 644 {} \; && \
91
+ chmod +x /home/user/app/app.py || true
92
 
93
+ # ---- Healthcheck ----
94
  HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD \
95
  ["python3","-c","import torch; print('torch', torch.__version__, '| cuda', getattr(torch.version,'cuda',None), '| ok=', torch.cuda.is_available())"]
96
 
97
  # ---- Runtime ----
98
  USER user
99
+ EXPOSE 8501
100
 
101
+ # Streamlit server command
102
  CMD ["sh", "-c", "\
103
  echo '===========================================' && \
104
+ echo '=== MYAVATAR STREAMLIT CONTAINER STARTUP ===' && \
105
  echo '===========================================' && \
106
  echo 'Timestamp:' $(date) && \
107
  echo 'Current directory:' $(pwd) && \
 
112
  echo 'Files in app directory:' && \
113
  ls -la && \
114
  echo '' && \
115
+ echo '=== APP.PY VERIFICATION ===' && \
116
+ if [ -f app.py ]; then \
117
+ echo 'βœ… app.py found' && \
118
+ echo 'File size:' $(wc -c < app.py) 'bytes' && \
119
+ echo 'File permissions:' $(ls -l app.py) && \
120
  echo 'Testing Python imports...' && \
121
+ python3 -B -c 'import streamlit; print(\"βœ… Streamlit:\", streamlit.__version__)' && \
122
  python3 -B -c 'import torch; print(\"βœ… Torch:\", torch.__version__)' && \
123
+ echo 'Testing app.py import...' && \
124
+ python3 -B -c 'import sys; sys.path.insert(0, \".\"); import app; print(\"βœ… app.py imports successfully\")' && \
125
  echo 'βœ… All checks passed!'; \
126
  else \
127
+ echo '❌ ERROR: app.py not found!' && \
128
  exit 1; \
129
  fi && \
130
  echo '' && \
131
+ echo '=== STARTING STREAMLIT SERVER ===' && \
132
+ streamlit run --server.port=8501 --server.address=0.0.0.0 app.py \
133
+ "]
 
VideoBackgroundReplacer2/requirements.txt CHANGED
@@ -1,27 +1,21 @@
1
- # ===== Core Dependencies =====
2
- # PyTorch is installed in Dockerfile with CUDA 12.1 β€” REQUIRED for SAM2
3
- # torch==2.5.1
4
- # torchvision==0.20.1
5
- # torchaudio==2.5.1
6
-
7
- # ===== Base Dependencies =====
8
- numpy>=1.24.0,<2.1.0
9
- Pillow>=10.0.0,<12.0.0
10
- protobuf>=4.25.0,<6.0.0
11
-
12
- # ===== Image/Video Processing =====
13
- opencv-python-headless>=4.8.0,<4.11.0
14
  imageio>=2.25.0,<3.0.0
15
- imageio-ffmpeg>=0.4.7,<0.6.0
16
  moviepy>=1.0.3,<2.0.0
17
  decord>=0.6.0,<0.7.0
18
  scikit-image>=0.19.3,<0.22.0
19
 
20
- # ===== MediaPipe =====
21
  mediapipe>=0.10.0,<0.11.0
22
 
23
- # ===== SAM2 Dependencies =====
24
- # SAM2 is installed via git clone in Dockerfile
25
  hydra-core>=1.3.2,<2.0.0
26
  omegaconf>=2.3.0,<3.0.0
27
  einops>=0.6.0,<0.9.0
@@ -30,43 +24,32 @@ pyyaml>=6.0.0,<7.0.0
30
  matplotlib>=3.5.0,<4.0.0
31
  iopath>=0.1.10,<0.2.0
32
 
33
- # ===== MatAnyone Dependencies =====
34
- # MatAnyone is installed separately in Dockerfile
35
  kornia>=0.7.0,<0.8.0
36
  tqdm>=4.60.0,<5.0.0
37
 
38
- # ===== UI and API =====
39
- # Bump to avoid gradio_client 1.3.0 bug ("bool is not iterable")
40
- gradio==4.42.0
41
 
42
- # ===== Web stack pins for Gradio 4.42.0 =====
43
- fastapi==0.109.2
44
- starlette==0.36.3
45
- uvicorn==0.29.0
46
- httpx==0.27.2
47
- anyio==4.4.0
48
- orjson>=3.10.0
49
 
50
- # ===== Pydantic family (avoid breaking core 2.23.x) =====
51
- pydantic==2.8.2
52
- pydantic-core==2.20.1
53
- annotated-types==0.6.0
54
- typing-extensions==4.12.2
55
 
56
- # ===== Helpers and Utilities =====
57
  huggingface-hub>=0.20.0,<1.0.0
58
  ffmpeg-python>=0.2.0,<1.0.0
59
  psutil>=5.8.0,<7.0.0
60
  requests>=2.25.0,<3.0.0
61
  scikit-learn>=1.3.0,<2.0.0
62
-
63
- # ===== Additional Dependencies =====
64
- # Performance and monitoring
65
- gputil>=1.4.0,<2.0.0
66
- nvidia-ml-py3>=7.352.0,<12.0.0
67
-
68
- # Error handling and logging
69
  loguru>=0.6.0,<1.0.0
70
-
71
- # File handling
72
- python-multipart>=0.0.5,<1.0.0
 
1
+ # Replace the current requirements.txt with this content:
2
+ echo "# Core Dependencies
3
+ numpy>=1.24.0,<2.0.0
4
+ Pillow>=10.0.0,<11.0.0
5
+ protobuf>=4.25.0,<5.0.0
6
+
7
+ # Image/Video Processing
8
+ opencv-python-headless>=4.8.0,<5.0.0
 
 
 
 
 
9
  imageio>=2.25.0,<3.0.0
10
+ imageio-ffmpeg>=0.4.7,<1.0.0
11
  moviepy>=1.0.3,<2.0.0
12
  decord>=0.6.0,<0.7.0
13
  scikit-image>=0.19.3,<0.22.0
14
 
15
+ # MediaPipe
16
  mediapipe>=0.10.0,<0.11.0
17
 
18
+ # SAM2 Dependencies
 
19
  hydra-core>=1.3.2,<2.0.0
20
  omegaconf>=2.3.0,<3.0.0
21
  einops>=0.6.0,<0.9.0
 
24
  matplotlib>=3.5.0,<4.0.0
25
  iopath>=0.1.10,<0.2.0
26
 
27
+ # MatAnyone Dependencies
 
28
  kornia>=0.7.0,<0.8.0
29
  tqdm>=4.60.0,<5.0.0
30
 
31
+ # Streamlit UI
32
+ streamlit>=1.32.0,<2.0.0
33
+ streamlit-webrtc>=0.50.0,<1.0.0
34
 
35
+ # Web stack
36
+ fastapi>=0.104.0,<1.0.0
37
+ uvicorn>=0.24.0,<1.0.0
38
+ httpx>=0.25.0,<1.0.0
39
+ anyio>=4.0.0,<5.0.0
40
+ orjson>=3.10.0,<4.0.0
 
41
 
42
+ # Pydantic
43
+ pydantic>=2.0.0,<3.0.0
44
+ pydantic-core>=2.0.0,<3.0.0
45
+ annotated-types>=0.5.0,<1.0.0
46
+ typing-extensions>=4.0.0,<5.0.0
47
 
48
+ # Helpers and Utilities
49
  huggingface-hub>=0.20.0,<1.0.0
50
  ffmpeg-python>=0.2.0,<1.0.0
51
  psutil>=5.8.0,<7.0.0
52
  requests>=2.25.0,<3.0.0
53
  scikit-learn>=1.3.0,<2.0.0
 
 
 
 
 
 
 
54
  loguru>=0.6.0,<1.0.0
55
+ python-multipart>=0.0.5,<1.0.0" > requirements.txt