mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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:
co-authored by
stirling-image
parent
e3bfa6585a
commit
8d8ab4bc45
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user