Spaces:
Paused
Paused
Commit ·
b1025e1
1
Parent(s): 57fa6f9
Fix: simple regex-based try/except wrapper for all wan submodule imports
Browse files- Dockerfile +29 -38
Dockerfile
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
-
#
|
|
|
|
| 2 |
|
| 3 |
FROM nvidia/cuda:12.4.0-runtime-ubuntu22.04
|
| 4 |
|
|
@@ -19,50 +20,40 @@ ENV PYTHONUNBUFFERED=1
|
|
| 19 |
|
| 20 |
WORKDIR /app
|
| 21 |
|
| 22 |
-
# Clone official Wan2.2
|
| 23 |
RUN git clone https://github.com/Wan-Video/Wan2.2.git /app/Wan2.2
|
| 24 |
|
| 25 |
# PyTorch
|
| 26 |
RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
|
| 27 |
|
| 28 |
-
#
|
| 29 |
-
RUN cd /app/Wan2.2 && (pip install --no-cache-dir -r requirements.txt 2>/dev/null; true)
|
| 30 |
-
|
| 31 |
-
# Fill in any missing deps aggressively
|
| 32 |
RUN pip install --no-cache-dir \
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
# Patch Wan2.2 to tolerate missing optional modules at import time
|
| 39 |
-
RUN python -c "
|
| 40 |
-
content = '''# Patched for Docker Space — tolerate missing optional modules
|
| 41 |
-
import importlib, sys
|
| 42 |
-
|
| 43 |
-
_module_fallbacks = {
|
| 44 |
-
'wan.speech2video': 'speech2video optional',
|
| 45 |
-
'wan.animate': 'animate optional',
|
| 46 |
-
}
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
''
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
| 66 |
|
| 67 |
# FastAPI
|
| 68 |
COPY --chown=user ./requirements.txt requirements.txt
|
|
|
|
| 1 |
+
# Wan2.2 TI2V 5B — Hugging Face Docker Space
|
| 2 |
+
# Uses official Wan2.2 inference code with native T2V + I2V support
|
| 3 |
|
| 4 |
FROM nvidia/cuda:12.4.0-runtime-ubuntu22.04
|
| 5 |
|
|
|
|
| 20 |
|
| 21 |
WORKDIR /app
|
| 22 |
|
| 23 |
+
# Clone official Wan2.2 repo
|
| 24 |
RUN git clone https://github.com/Wan-Video/Wan2.2.git /app/Wan2.2
|
| 25 |
|
| 26 |
# PyTorch
|
| 27 |
RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
|
| 28 |
|
| 29 |
+
# Core ML deps
|
|
|
|
|
|
|
|
|
|
| 30 |
RUN pip install --no-cache-dir \
|
| 31 |
+
diffusers>=0.31.0 \
|
| 32 |
+
"transformers>=4.49.0,<=4.51.3" \
|
| 33 |
+
tokenizers>=0.20.3 \
|
| 34 |
+
accelerate>=1.1.1 \
|
| 35 |
+
peft
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
# All other deps
|
| 38 |
+
RUN pip install --no-cache-dir \
|
| 39 |
+
opencv-python easydict decord einops ftfy "numpy>=1.23.5,<2" \
|
| 40 |
+
tqdm "imageio[ffmpeg]" imageio-ffmpeg sentencepiece \
|
| 41 |
+
protobuf soundfile librosa
|
| 42 |
+
|
| 43 |
+
# Patch Wan2.2 init to silently skip optional/unsupported modules
|
| 44 |
+
RUN python3 -c "
|
| 45 |
+
import re
|
| 46 |
+
p = '/app/Wan2.2/wan/__init__.py'
|
| 47 |
+
c = open(p).read()
|
| 48 |
+
# Replace all 'from .X import' with try/except wrapper
|
| 49 |
+
c = re.sub(
|
| 50 |
+
r'from (\.\\S+) import (.+)',
|
| 51 |
+
r'try:\n from \\1 import \\2\nexcept ImportError:\n pass',
|
| 52 |
+
c
|
| 53 |
+
)
|
| 54 |
+
open(p, 'w').write(c)
|
| 55 |
+
print('Patched!')
|
| 56 |
+
" && cat /app/Wan2.2/wan/__init__.py | head -30
|
| 57 |
|
| 58 |
# FastAPI
|
| 59 |
COPY --chown=user ./requirements.txt requirements.txt
|