Instructions to use aacudad/AnomalyThink-LLaVA-OneVision-7B-KCR-corrected with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use aacudad/AnomalyThink-LLaVA-OneVision-7B-KCR-corrected with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="aacudad/AnomalyThink-LLaVA-OneVision-7B-KCR-corrected") 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("aacudad/AnomalyThink-LLaVA-OneVision-7B-KCR-corrected") model = AutoModelForMultimodalLM.from_pretrained("aacudad/AnomalyThink-LLaVA-OneVision-7B-KCR-corrected", device_map="auto") 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 aacudad/AnomalyThink-LLaVA-OneVision-7B-KCR-corrected with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "aacudad/AnomalyThink-LLaVA-OneVision-7B-KCR-corrected" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aacudad/AnomalyThink-LLaVA-OneVision-7B-KCR-corrected", "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/aacudad/AnomalyThink-LLaVA-OneVision-7B-KCR-corrected
- SGLang
How to use aacudad/AnomalyThink-LLaVA-OneVision-7B-KCR-corrected 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 "aacudad/AnomalyThink-LLaVA-OneVision-7B-KCR-corrected" \ --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": "aacudad/AnomalyThink-LLaVA-OneVision-7B-KCR-corrected", "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 "aacudad/AnomalyThink-LLaVA-OneVision-7B-KCR-corrected" \ --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": "aacudad/AnomalyThink-LLaVA-OneVision-7B-KCR-corrected", "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 aacudad/AnomalyThink-LLaVA-OneVision-7B-KCR-corrected with Docker Model Runner:
docker model run hf.co/aacudad/AnomalyThink-LLaVA-OneVision-7B-KCR-corrected
AnomalyThink-LLaVA-OneVision-7B-KCR-corrected
The Keep-Correct-Revise (KCR) replication on LLaVA-OneVision-7B-SI, corrected corpus build. This is the checkpoint the thesis reports as the second-backbone replication result (Table 6.13, Appendix M): DS-MVTec 87.32 / VisA 72.65 at the DS-MVTec-selected epoch 2, and 74.29 on VisA at epoch 4.
Why a corrected build
The first LLaVA KCR corpus, behind AnomalyThink-LLaVA-OneVision-7B-KCR (88.45 / 74.25), was drawn from the whole 10,236-image rollout pool rather than from the 6,000-image SFT split (3,516 of its images lie inside that split) and was balanced on the folder name rather than on the trace verdict, which left it at 45.0 % anomalous. The corrected corpus, llava_kcr/sft_llava_C_corrected_train.json in the dataset repo, keeps the same keep, correct and rewrite routing, the same record schema, prompt, caps and seed, and changes only those two things: all 6,000 images inside the SFT split and exactly 3,000 / 3,000 by verdict. That makes the comparison with the Qwen2.5-VL KCR model a one-factor comparison, which is why the thesis reports this build.
Results (MMAD subsets, balanced accuracy, strict scoring)
| Model | DS-MVTec | VisA |
|---|---|---|
| LLaVA-OneVision-7B-SI base | 75.66 | 53.80 |
| AnomalyThink LLaVA SFT (6K Gemini traces) | 85.91 | 68.26 |
| AnomalyThink LLaVA SFT then GRPO | 87.66 | 72.38 |
| AnomalyThink LLaVA KCR, first build | 88.45 | 74.25 |
| This model, corrected build, epoch 2 | 87.32 | 72.65 |
| IAD-R1 released checkpoint (Qwen2.5-VL-7B) | 81.92 | 71.34 |
Per epoch: 84.35 / 71.36, 87.32 / 72.65, 86.96 / 73.57, 86.60 / 74.29. On the held-out Real-IAD split (4,236 unseen images of seen products) this checkpoint scores 84.03, the highest row there.
Contamination note. The public LLaVA-OneVision instruction mixture contains entries naming MVTec-AD, so every DS-MVTec number on this backbone carries a possible pretraining-exposure caveat. VisA has no such entries. Claims that depend on this backbone are made on VisA.
Evaluation protocol. One harness for every row: the DS-MVTec (1,670 images) and VisA (2,141 images) subsets of MMAD, one image per prompt, the training prompt with the one-line system message "Please answer by yes or no", greedy decoding, at most 1,024 new tokens, images capped at 262,144 pixels, vLLM generation; 13 of the 2,141 VisA generations of this checkpoint carry no parsable verdict and are counted as wrong. Balanced accuracy is the mean of sensitivity and specificity. Strict scoring: a generation with no parsable <answer> counts as wrong. Per-sample evaluation files are next to the weights (eval_*.json).
Training
- Base:
llava-hf/llava-onevision-qwen2-7b-si-hf. - Corpus:
llava_kcr/sft_llava_C_corrected_train.json, 6,000 traces, 3,000 / 3,000 by verdict, all inside the SFT split, built from this backbone's own SFT then GRPO rollouts (k = 8 at temperature 0.7), judged and repaired by Gemini-3-Flash. - Recipe: supervised fine-tuning from base, SigLIP vision tower frozen, projector and language model trained, learning rate 1e-5, cosine, effective batch 32, DeepSpeed ZeRO-3 with optimizer offload, 4 epochs. This is epoch 2 (step 376).
Usage
Loads with transformers 4.51 to 4.57 as a LlavaOnevisionForConditionalGeneration. This backbone does not attend to the system turn, so put the instruction in the user turn: prepend "Please answer by yes or no." to the question. Same prompt and tags as the other AnomalyThink models.
Citation
@mastersthesis{acudad2026reasoning,
author = {Acudad, A.},
title = {Reasoning-Enhanced Vision-Language Models for Explainable Industrial Anomaly Detection},
school = {Delft University of Technology},
year = {2026},
type = {Master's thesis},
url = {https://resolver.tudelft.nl/uuid:65c62420-79c0-447f-b095-7fb11d4474fc}
}
Thesis: https://resolver.tudelft.nl/uuid:65c62420-79c0-447f-b095-7fb11d4474fc. Code and evaluation files: https://github.com/aacudad/IAD-VLMs.
License
Apache-2.0, derived from llava-hf/llava-onevision-qwen2-7b-si-hf.
- Downloads last month
- 20
Model tree for aacudad/AnomalyThink-LLaVA-OneVision-7B-KCR-corrected
Base model
llava-hf/llava-onevision-qwen2-7b-si-hf