Skip to content

Commit 668316c

Browse files
committed
build(runpod): add missing Dockerfile and setup files inside runpod context directory to fix GitHub Actions build failure
1 parent ddbd03c commit 668316c

8 files changed

Lines changed: 59 additions & 253 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ __pycache__/
33
.DS_Store
44
weights/
55
*.pth
6+
**/weights/
7+
**/tmp/

cog.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.

predict.py

Lines changed: 0 additions & 89 deletions
This file was deleted.

run.py

Lines changed: 0 additions & 149 deletions
This file was deleted.

runpod/Dockerfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM pytorch/pytorch:2.4.0-cuda12.4-cudnn9-runtime
2+
3+
# System deps for opencv
4+
RUN apt-get update && apt-get install -y libxcb1 libgl1-mesa-glx libglib2.0-0 && rm -rf /var/lib/apt/lists/*
5+
6+
# Install python dependencies including GFPGAN for face enhancement
7+
RUN pip install --no-cache-dir opencv-python-headless basicsr realesrgan gfpgan runpod
8+
9+
# Patch basicsr without importing it (compatibility patch for newer PyTorch/torchvision)
10+
RUN python -c "\
11+
import importlib.util, os;\
12+
spec = importlib.util.find_spec('basicsr');\
13+
path = os.path.join(os.path.dirname(spec.origin), 'data', 'degradations.py');\
14+
content = open(path).read();\
15+
content = content.replace(\
16+
'from torchvision.transforms.functional_tensor import rgb_to_grayscale',\
17+
'from torchvision.transforms.functional import rgb_to_grayscale');\
18+
open(path, 'w').write(content);\
19+
print('Patched:', path)\
20+
"
21+
22+
# Pre-download core upscale and face enhancement weights so cold start is fast
23+
RUN mkdir -p /weights && python -c "\
24+
import urllib.request;\
25+
print('Downloading Real-ESRGAN weights...');\
26+
urllib.request.urlretrieve('https://huggingface.co/nateraw/real-esrgan/resolve/main/RealESRGAN_x2plus.pth', '/weights/RealESRGAN_x2plus.pth');\
27+
urllib.request.urlretrieve('https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth', '/weights/RealESRGAN_x4plus.pth');\
28+
urllib.request.urlretrieve('https://huggingface.co/Kim2091/UltraSharp/resolve/main/4x-UltraSharp.pth', '/weights/4x-UltraSharp.pth');\
29+
urllib.request.urlretrieve('https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth', '/weights/RealESRGAN_x4plus_anime_6B.pth');\
30+
print('Downloading GFPGAN weights...');\
31+
urllib.request.urlretrieve('https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth', '/weights/GFPGANv1.3.pth');\
32+
print('Pre-download core weights completed!')\
33+
"
34+
35+
# Trigger gfpgan/facexlib auto-download for face helper models during build to prevent cold start latency
36+
RUN python -c "\
37+
import sys, os, types;\
38+
import torchvision.transforms.functional as F_tv;\
39+
shim = types.ModuleType('torchvision.transforms.functional_tensor');\
40+
shim.rgb_to_grayscale = F_tv.rgb_to_grayscale;\
41+
sys.modules['torchvision.transforms.functional_tensor'] = shim;\
42+
from gfpgan import GFPGANer;\
43+
from realesrgan import RealESRGANer;\
44+
from basicsr.archs.rrdbnet_arch import RRDBNet;\
45+
model = RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=2);\
46+
upsampler = RealESRGANer(scale=2, model_path='/weights/RealESRGAN_x2plus.pth', model=model);\
47+
GFPGANer(model_path='/weights/GFPGANv1.3.pth', upscale=2, arch='clean', channel_multiplier=2, bg_upsampler=upsampler);\
48+
print('Pre-download face helper detection/parsing models completed!')\
49+
"
50+
51+
COPY rp_handler.py /rp_handler.py
52+
53+
CMD ["python", "-u", "/rp_handler.py"]
File renamed without changes.

runpod/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
numpy<2
2+
opencv-python-headless==4.10.0.84
3+
Pillow==10.4.0
4+
tqdm==4.64.0

test.jpeg

-3.15 MB
Binary file not shown.

0 commit comments

Comments
 (0)