fix(docker): close remaining airgap gaps for fully offline operation (#70)

Three fixes to ensure zero network access after docker pull:

1. rembg model allowlist: validate model parameter against the 7
   pre-downloaded models, preventing rembg from attempting to download
   unknown models via a raw API call.

2. GFPGAN/CodeFormer auxiliary models: pre-download facexlib's
   detection_Resnet50_Final.pth and parsing_parsenet.pth at build time.
   These were previously downloaded on first use via basicsr. Symlinks
   in /app/gfpgan/weights/ ensure codeformer-pip also finds them.

3. OpenCV colorize models: pre-download the prototxt, caffemodel, and
   pts_in_hull.npy so the lightweight OpenCV colorizer fallback works
   in addition to the primary DDColor method.

Co-authored-by: stirling-image <stirling-image@users.noreply.github.com>
This commit is contained in:
stirling-image
2026-04-14 16:51:46 +08:00
committed by GitHub
co-authored by stirling-image
parent e3bfa6585a
commit 8d8ab4bc45
3 changed files with 112 additions and 0 deletions
+12
View File
@@ -9,6 +9,16 @@ def emit_progress(percent, stage):
print(json.dumps({"progress": percent, "stage": stage}), file=sys.stderr, flush=True)
ALLOWED_MODELS = {
"u2net",
"isnet-general-use",
"bria-rmbg",
"birefnet-general-lite",
"birefnet-portrait",
"birefnet-general",
"birefnet-matting",
}
_matting_registered = False
def _register_matting_session(sessions_class):
@@ -48,6 +58,8 @@ def main():
settings = json.loads(sys.argv[3]) if len(sys.argv) > 3 else {}
model = settings.get("model", "birefnet-general-lite")
if model not in ALLOWED_MODELS:
model = "birefnet-general-lite"
# Redirect stdout to stderr so library download/progress output
# cannot contaminate our JSON result on stdout.