Spaces:
Paused
Paused
Commit ·
e99b3c1
1
Parent(s): 694d214
Fix: install ALL deps + patch both wan/__init__.py and generate.py for optional imports
Browse files- Dockerfile +26 -18
Dockerfile
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
-
#
|
| 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,36 +19,45 @@ ENV PYTHONUNBUFFERED=1
|
|
| 20 |
|
| 21 |
WORKDIR /app
|
| 22 |
|
| 23 |
-
# Clone official Wan2.2
|
| 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 |
-
#
|
| 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 |
-
#
|
| 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 |
-
#
|
| 44 |
-
COPY --chown=user ./patch_wan_init.py /tmp/patch_wan_init.py
|
| 45 |
RUN python3 /tmp/patch_wan_init.py && \
|
| 46 |
-
head -
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
# Copy app
|
|
|
|
|
|
|
| 53 |
COPY --chown=user ./app.py app.py
|
| 54 |
COPY --chown=user ./README.md README.md
|
| 55 |
|
|
|
|
| 1 |
+
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
|
|
|
| 2 |
|
| 3 |
FROM nvidia/cuda:12.4.0-runtime-ubuntu22.04
|
| 4 |
|
|
|
|
| 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 |
+
# Patch wan/__init__.py and generate.py for optional submodules
|
| 26 |
+
COPY --chown=user ./patch_wan_init.py /tmp/patch_wan_init.py
|
| 27 |
+
|
| 28 |
# PyTorch
|
| 29 |
RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
|
| 30 |
|
| 31 |
+
# Install all Wan2.2 deps (flash_attn may fail, that's ok)
|
| 32 |
+
RUN cd /app/Wan2.2 && (pip install --no-cache-dir -r requirements.txt 2>/dev/null; exit 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
# Install any remaining deps explicitly
|
| 35 |
RUN pip install --no-cache-dir \
|
| 36 |
opencv-python easydict decord einops ftfy "numpy>=1.23.5,<2" \
|
| 37 |
tqdm "imageio[ffmpeg]" imageio-ffmpeg sentencepiece \
|
| 38 |
+
protobuf soundfile librosa peft dashscope
|
| 39 |
|
| 40 |
+
# Apply patches
|
|
|
|
| 41 |
RUN python3 /tmp/patch_wan_init.py && \
|
| 42 |
+
head -5 /app/Wan2.2/wan/__init__.py
|
| 43 |
|
| 44 |
+
RUN python3 -c "
|
| 45 |
+
# Patch generate.py to make dashscope optional
|
| 46 |
+
p = '/app/Wan2.2/generate.py'
|
| 47 |
+
with open(p) as f:
|
| 48 |
+
c = f.read()
|
| 49 |
+
c = c.replace(
|
| 50 |
+
'from wan.utils.prompt_extend import DashScopePromptExpander, QwenPromptExpander',
|
| 51 |
+
'try:\n from wan.utils.prompt_extend import DashScopePromptExpander, QwenPromptExpander\nexcept ImportError:\n DashScopePromptExpander = None\n QwenPromptExpander = None'
|
| 52 |
+
)
|
| 53 |
+
with open(p, 'w') as f:
|
| 54 |
+
f.write(c)
|
| 55 |
+
print('Patched generate.py')
|
| 56 |
+
"
|
| 57 |
|
| 58 |
# Copy app
|
| 59 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
| 60 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 61 |
COPY --chown=user ./app.py app.py
|
| 62 |
COPY --chown=user ./README.md README.md
|
| 63 |
|