sayeed105236 commited on
Commit
b1025e1
·
1 Parent(s): 57fa6f9

Fix: simple regex-based try/except wrapper for all wan submodule imports

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -38
Dockerfile CHANGED
@@ -1,4 +1,5 @@
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,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
- # Install everything from the Wan2.2 requirements (flash_attn may fail on T4, that's ok)
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
- opencv-python easydict decord librosa peft sentencepiece protobuf \
34
- diffusers transformers accelerate tokenizers \
35
- tqdm ftfy "imageio[ffmpeg]" imageio-ffmpeg einops \
36
- "numpy>=1.23.5,<2" soundfile
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
- _orig_import = __import__
49
- def _safe_import(name, *args, **kwargs):
50
- try:
51
- return _orig_import(name, *args, **kwargs)
52
- except (ImportError, ModuleNotFoundError) as e:
53
- if name in _module_fallbacks:
54
- return type(sys)(name)
55
- raise
56
-
57
- import builtins
58
- builtins.__import__ = _safe_import
59
- '''
60
- with open('/app/Wan2.2/wan/__init__.py', 'r') as f:
61
- original = f.read()
62
- with open('/app/Wan2.2/wan/__init__.py', 'w') as f:
63
- f.write(content + '\\n' + original)
64
- print('Patched wan/__init__.py')
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