Instructions to use P1n3/sdg-detector-sft with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use P1n3/sdg-detector-sft with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="P1n3/sdg-detector-sft") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("P1n3/sdg-detector-sft") model = AutoModelForMultimodalLM.from_pretrained("P1n3/sdg-detector-sft") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use P1n3/sdg-detector-sft with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "P1n3/sdg-detector-sft" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "P1n3/sdg-detector-sft", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/P1n3/sdg-detector-sft
- SGLang
How to use P1n3/sdg-detector-sft with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "P1n3/sdg-detector-sft" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "P1n3/sdg-detector-sft", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "P1n3/sdg-detector-sft" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "P1n3/sdg-detector-sft", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use P1n3/sdg-detector-sft with Docker Model Runner:
docker model run hf.co/P1n3/sdg-detector-sft
SDG Detector — SFT Stage
Stage-1 supervised fine-tuning of Qwen/Qwen3-VL-4B-Instruct on the SDG-30K
training split. This checkpoint backs the "SDG (SFT)" row of Table 1 in the
SDG paper.
The model emits structured defect-grounding output:
<think>
[Caption Understanding -> Visual Analysis -> Defect Spotting -> Localization]
</think>
<answer>
[
{"box_2d": [y0, x0, y1, x1], "label": "artifact" | "misalignment", "desc": "..."},
...
]
</answer>
box_2d uses the [0, 1000] normalized convention (top, left, bottom, right).
Training summary
| field | value |
|---|---|
| base model | Qwen/Qwen3-VL-4B-Instruct |
| training data | SDG-30K train split (~85,770 prompt-response pairs after CoT distillation + jitter) |
| epochs | 1 effective (5,360 steps × effective batch 16) |
| learning rate | 3.0e-5, cosine, 5% warmup |
| coord jitter | ±10 px, per-epoch resampling |
| vision encoder | frozen |
| precision | bf16 |
| hardware | 16 × A100-80G (2 nodes × 8) |
| optimizer state | not redistributed (release-only checkpoint) |
Quick start
from transformers import AutoProcessor, AutoModelForImageTextToText
import torch
ckpt = "P1n3/sdg-detector-sft"
processor = AutoProcessor.from_pretrained(ckpt)
model = AutoModelForImageTextToText.from_pretrained(
ckpt, dtype=torch.bfloat16, device_map="auto",
)
The exact prompt template lives in the supplementary archive at
sdg_detector/train/constants.py (question_template_registry).
Stage-2 GRPO Checkpoint
The Stage-2 GRPO detector is released separately as a merged full checkpoint:
P1n3/sdg-detector-grpo. It can be loaded directly with transformers and
should not be attached as a PEFT adapter.
License
cc-by-nc-4.0. Derivative of Qwen/Qwen3-VL-4B-Instruct (Apache-2.0). Released
for non-commercial research use only.
Citation
@article{zhang2026and,
title={Where, What, Why, and Importance: Structured Defect Grounding for Text-to-Image Feedback},
author={Zhang, Huaisong and Yu, Hao and Zhang, Yuxuan and Wang, Jiahe and Chen, Xinrui and Cao, Haoxiang and Lu, Feng and Zhang, Wendong and Yu, Changqian and Yuan, Chun},
journal={arXiv preprint arXiv:2606.06113},
year={2026}
}
- Downloads last month
- -