Spaces:
Running on Zero
Running on Zero
| from __future__ import annotations | |
| import ast | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent | |
| REQUIRED = { | |
| ".gitignore", | |
| "app.py", | |
| "star_utils.py", | |
| "README.md", | |
| "requirements.txt", | |
| "pre-requirements.txt", | |
| "DEPLOY.md", | |
| "DEPLOY_KO.md", | |
| "LICENSE", | |
| "THIRD_PARTY_NOTICES.md", | |
| "tests/test_star_utils.py", | |
| } | |
| missing = sorted(name for name in REQUIRED if not (ROOT / name).is_file()) | |
| if missing: | |
| raise SystemExit(f"Missing files: {', '.join(missing)}") | |
| for relative in ( | |
| "app.py", | |
| "star_utils.py", | |
| "validate_space.py", | |
| "tests/test_star_utils.py", | |
| ): | |
| path = ROOT / relative | |
| ast.parse(path.read_text(encoding="utf-8"), filename=str(path)) | |
| readme = (ROOT / "README.md").read_text(encoding="utf-8") | |
| for marker in ( | |
| "sdk: gradio", | |
| "sdk_version: 6.20.0", | |
| "python_version: 3.12.12", | |
| "app_file: app.py", | |
| "startup_duration_timeout: 1h", | |
| "preload_from_hub:", | |
| "Qwen/Qwen3-VL-8B-Instruct", | |
| "sj9909/StAR-8B", | |
| "facebook/sam2.1-hiera-large", | |
| ): | |
| if marker not in readme: | |
| raise SystemExit(f"README metadata is missing: {marker}") | |
| requirements = (ROOT / "requirements.txt").read_text(encoding="utf-8") | |
| for marker in ( | |
| "gradio==6.20.0", | |
| "spaces==0.50.4", | |
| "transformers==5.13.0", | |
| "accelerate==1.14.0", | |
| "peft==0.19.1", | |
| "safetensors==0.8.0", | |
| "huggingface-hub==1.22.0", | |
| "git+https://github.com/facebookresearch/sam2.git@2b90b9f", | |
| ): | |
| if marker not in requirements: | |
| raise SystemExit(f"requirements.txt is missing: {marker}") | |
| if "qwen-vl-utils" in requirements: | |
| raise SystemExit("qwen-vl-utils should not be required by this package") | |
| pre_requirements = (ROOT / "pre-requirements.txt").read_text(encoding="utf-8") | |
| for marker in ("torch==2.9.1", "torchvision==0.24.1"): | |
| if marker not in pre_requirements: | |
| raise SystemExit(f"pre-requirements.txt is missing: {marker}") | |
| app = (ROOT / "app.py").read_text(encoding="utf-8") | |
| for marker in ( | |
| "@spaces.GPU", | |
| 'size="large"', | |
| 'attn_implementation="sdpa"', | |
| "dtype=torch.bfloat16", | |
| "apply_chat_template(", | |
| "rewrite_lora_state_dict_keys", | |
| "reset_predictor()", | |
| "concurrency_limit=1", | |
| ): | |
| if marker not in app: | |
| raise SystemExit(f"app.py is missing: {marker}") | |
| print("Space package validation passed.") | |