Spaces:
Running on Zero
Running on Zero
Download app.py from VincentHancoder/RAP: direct link, hf CLI and curl.
- Browser
- Download file 1.6 kB
-
https://huggingface.co/spaces/VincentHancoder/RAP/resolve/main/app.py
- Command line
-
hf download hf://spaces/VincentHancoder/RAP/app.py
-
curl -L -o app.py https://huggingface.co/spaces/VincentHancoder/RAP/resolve/main/app.py
1.6 kB
| """RAP RL checkpoint-240 on ZeroGPU; BF16 weights, no quantization.""" | |
| import spaces | |
| import os | |
| os.environ.setdefault('HF_HUB_DISABLE_PROGRESS_BARS','1') | |
| os.environ.setdefault('TOKENIZERS_PARALLELISM','false') | |
| import json | |
| import shutil | |
| import time | |
| from pathlib import Path | |
| import torch | |
| import gradio as gr | |
| import psutil | |
| from transformers import AutoModelForImageTextToText, AutoProcessor | |
| from demo_ui import build | |
| REPO = "VincentHancoder/RAP-Qwen3.8-27B-RL" | |
| REVISION = "50f3adc4ebb9b19e53ef9c21c293993a77bf3fd7" | |
| print("STARTUP", json.dumps({"ram_gib": psutil.virtual_memory().total / 2**30, | |
| "disk_free_gib": shutil.disk_usage(".").free / 2**30, | |
| "torch": torch.__version__}), flush=True) | |
| processor = AutoProcessor.from_pretrained(REPO, revision=REVISION, token=os.environ.get("HF_TOKEN")) | |
| model = AutoModelForImageTextToText.from_pretrained( | |
| REPO, revision=REVISION, token=os.environ.get("HF_TOKEN"), dtype=torch.bfloat16, | |
| device_map="cuda:0", attn_implementation="sdpa", | |
| ) | |
| model.eval() | |
| model.config.use_cache = True | |
| model.config.text_config.use_cache = True | |
| print("RAP_MODEL_READY", flush=True) | |
| demo, artifacts = build(model, processor) | |
| demo.queue(default_concurrency_limit=1, max_size=8).launch( | |
| show_error=False, max_file_size='40mb', ssr_mode=False, | |
| allowed_paths=[str(artifacts),str(Path(__file__).parent/'examples')], | |
| blocked_paths=[str(__import__('pathlib').Path(__file__).parent/'.runtime'), | |
| '/root/.cache/huggingface','/home/user/.cache/huggingface', | |
| '/etc','/proc','/sys'], | |
| ) | |