--- library_name: transformers tags: - image-scoring - regression - lora - peft --- # alecccdd/ratebv-frwo-r1-model Continuous image scorer: maps an image to a score in `[0, 1000]`. Backbone: vendored Sapiens2 ViT (`sapiens2_0.8b`) (frozen) with a LoRA adapter applied at load time, plus a small regression head. Exported from training run `jvcead4r`. ## Usage ```python from transformers import AutoModel model = AutoModel.from_pretrained("alecccdd/ratebv-frwo-r1-model", trust_remote_code=True).eval() model.predict("photo.jpg") # -> float in [0, 1000] model.predict(["a.jpg", "b.jpg"]) # -> list[float] ``` The base backbone `facebook/sapiens2-pretrain-0.8b` is **gated** on the HuggingFace Hub. Before loading, accept its license and make sure `HF_TOKEN` is set — only the LoRA adapter and head are stored here; the base weights are downloaded at load time. ```python from huggingface_hub import login login("hf_...") # a token with the base model's license accepted ``` ## What's inside | File | Purpose | | --- | --- | | `model.py` / `sapiens2.py` | self-contained model code (loaded via `trust_remote_code`) | | `config.json` | `ScorerConfig` (`auto_map` -> `ScorerConfig` / `ScorerModel`) | | `adapter/adapter_config.json`, `adapter/adapter_model.safetensors` | the LoRA adapter (NOT merged) | | `head.pt` | the regression head weights | ## How it works 1. Load the frozen backbone `facebook/sapiens2-pretrain-0.8b` and apply the LoRA adapter (`peft`). 2. Pool the CLS embedding and run the regression head -> a sigmoid in `[0, 1]`. 3. Denormalize: `score = sigmoid * (1000 - 0) + 0`. Preprocessing: `preserve_aspect=True`, `image_size=[296, 222]`, `patch_size=16`, `image_mean=[0.485, 0.456, 0.406]`, `image_std=[0.229, 0.224, 0.225]`. Head: `hidden_size=1280`, `hidden_dims=[] (minimal head)`, `dropout=0.45`. ## Provenance Source run `jvcead4r` — val_mae=63.50330494869472, val_r2=0.9078422463529856. ## Requirements `torch`, `torchvision`, `transformers>=5.9`, `peft>=0.19`, `huggingface_hub`, `safetensors`, `numpy`, `pillow`.