Image-Text-to-Text
Transformers
Safetensors
English
cviu_chat
feature-extraction
qupaint
2d-materials
quantum-materials
microscopy
scientific-discovery
multimodal
visual-grounding
cvpr2026
conversational
custom_code
Instructions to use uark-cviu/QuPAINT-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use uark-cviu/QuPAINT-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="uark-cviu/QuPAINT-4B", trust_remote_code=True) 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("uark-cviu/QuPAINT-4B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use uark-cviu/QuPAINT-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "uark-cviu/QuPAINT-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "uark-cviu/QuPAINT-4B", "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/uark-cviu/QuPAINT-4B
- SGLang
How to use uark-cviu/QuPAINT-4B 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 "uark-cviu/QuPAINT-4B" \ --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": "uark-cviu/QuPAINT-4B", "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 "uark-cviu/QuPAINT-4B" \ --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": "uark-cviu/QuPAINT-4B", "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 uark-cviu/QuPAINT-4B with Docker Model Runner:
docker model run hf.co/uark-cviu/QuPAINT-4B
Download postprocess.py from uark-cviu/QuPAINT-4B: direct link, hf CLI and curl.
- Browser
- Download file 2.06 kB
-
https://huggingface.co/uark-cviu/QuPAINT-4B/resolve/main/postprocess.py
- Command line
-
hf download hf://uark-cviu/QuPAINT-4B/postprocess.py
-
curl -L -o postprocess.py https://huggingface.co/uark-cviu/QuPAINT-4B/resolve/main/postprocess.py
2.06 kB
| """Parsing and visualisation of QuPAINT responses. | |
| QuPAINT answers in free text and closes with a `<CONCLUSION>` span that holds the | |
| flakes it commits to, each as a `<box>x, y, w, h</box>` quadruple in **percent** | |
| of image width/height (top-left origin). | |
| """ | |
| import re | |
| from typing import List, Sequence, Tuple | |
| CONCLUSION_RE = re.compile(r"<\s*/?\s*CONCLUSION>(.*?)<\s*/?\s*CONCLUSION>", re.DOTALL) | |
| BOX_RE = re.compile(r"<box>(.*?)</box>", re.DOTALL) | |
| Box = Tuple[float, float, float, float] | |
| def parse_conclusion_boxes(response: str) -> List[Box]: | |
| """Return the `<box>` quadruples inside the `<CONCLUSION>` span, in percent.""" | |
| match = CONCLUSION_RE.search(response) | |
| if not match: | |
| return [] | |
| boxes = [] | |
| for raw in BOX_RE.findall(match.group(1)): | |
| try: | |
| coords = [float(v.strip()) for v in raw.split(",")] | |
| except ValueError: | |
| continue | |
| if len(coords) == 4: | |
| boxes.append(tuple(coords)) | |
| return boxes | |
| def denorm_box(box: Box, height: int, width: int) -> Tuple[int, int, int, int]: | |
| """Percent box (x, y, w, h) -> pixel box (x, y, w, h) for a `height` x `width` image.""" | |
| x, y, w, h = box | |
| return ( | |
| int(x / 100 * width), | |
| int(y / 100 * height), | |
| int(w / 100 * width), | |
| int(h / 100 * height), | |
| ) | |
| def parse_boxes(response: str, height: int, width: int) -> List[Tuple[int, int, int, int]]: | |
| """Parse a response straight into pixel boxes for an image of the given size.""" | |
| return [denorm_box(box, height, width) for box in parse_conclusion_boxes(response)] | |
| def draw_boxes( | |
| image, | |
| boxes: Sequence[Tuple[int, int, int, int]], | |
| color: Tuple[int, int, int] = (255, 255, 0), | |
| thickness: int = 2, | |
| ): | |
| """Draw pixel boxes onto a PIL image and return a new annotated image.""" | |
| from PIL import ImageDraw | |
| annotated = image.convert("RGB").copy() | |
| draw = ImageDraw.Draw(annotated) | |
| for x, y, w, h in boxes: | |
| draw.rectangle([x, y, x + w, y + h], outline=color, width=thickness) | |
| return annotated | |