Spaces:
Running on Zero
Running on Zero
Download app.py from AST-1320/Testbase-0.2: direct link, hf CLI and curl.
- Browser
- Download file 1.95 kB
-
https://huggingface.co/spaces/AST-1320/Testbase-0.2/resolve/main/app.py
- Command line
-
hf download hf://spaces/AST-1320/Testbase-0.2/app.py
-
curl -L -o app.py https://huggingface.co/spaces/AST-1320/Testbase-0.2/resolve/main/app.py
1.95 kB
| import os | |
| import runpy | |
| import sys | |
| from huggingface_hub import snapshot_download | |
| MODELS = { | |
| "Qwen/Qwen-Image-Edit-2511": "Base model (supplies the text encoder, VAE, tokenizer and scheduler; its transformer is replaced by the tuned one)", | |
| "Phr00t/Qwen-Image-Edit-Rapid-AIO": "Tuned accelerated transformer weights for 4-step image editing (replaces the base transformer)", | |
| "black-forest-labs/FLUX.2-klein-4B": "Image refinement model (option 1 of 3, one is used at a time)", | |
| "black-forest-labs/FLUX.2-klein-9B": "Image refinement model (option 2 of 3, one is used at a time)", | |
| "black-forest-labs/FLUX.2-klein-9b-kv": "Image refinement model (option 3 of 3, one is used at a time)", | |
| "nateraw/vit-age-classifier": "Age verification model (classifies the age bracket of detected face crops)", | |
| "LiquidAI/LFM2.5-VL-450M": "Age verification VLM (primary, first-pass check on every image)", | |
| "OpenGVLab/InternVL3-1B-hf": "Age verification VLM (fallback, loaded only when the primary cannot be loaded)", | |
| } | |
| NON_HUB_COMPONENTS = { | |
| "YuNet face detector (OpenCV Zoo, face_detection_yunet_2023mar.onnx)": "Face detection for age verification (primary detector)", | |
| "MediaPipe BlazeFace short-range face detector (Google)": "Face detection for age verification (secondary detector)", | |
| "OpenCV Haar cascade frontal face detector (OpenCV built-in)": "Face detection for age verification (last-resort fallback)", | |
| } | |
| def _require_env(name): | |
| value = (os.environ.get(name) or "").strip() | |
| if not value: | |
| raise RuntimeError(f"Missing required Space secret: {name}") | |
| return value | |
| code_folder = _require_env("CODE_DIR") | |
| snapshot = snapshot_download( | |
| repo_id=_require_env("CODE_REPO"), | |
| token=_require_env("HF_TOKEN"), | |
| allow_patterns=[f"{code_folder}/*"], | |
| ) | |
| code_dir = os.path.join(snapshot, code_folder) | |
| sys.path.insert(0, code_dir) | |
| runpy.run_path(os.path.join(code_dir, "app.py"), run_name="__main__") | |