CFCamo: A Counterfactual Detect-or-Abstain Framework for Camouflaged Object Detection
Paper • 2606.11231 • Published
How to use cfcamo/cfcamo-sft-4b with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-text-to-text", model="cfcamo/cfcamo-sft-4b")
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("cfcamo/cfcamo-sft-4b")
model = AutoModelForMultimodalLM.from_pretrained("cfcamo/cfcamo-sft-4b")
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]:]))How to use cfcamo/cfcamo-sft-4b with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "cfcamo/cfcamo-sft-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": "cfcamo/cfcamo-sft-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 run hf.co/cfcamo/cfcamo-sft-4b
How to use cfcamo/cfcamo-sft-4b with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "cfcamo/cfcamo-sft-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": "cfcamo/cfcamo-sft-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 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 "cfcamo/cfcamo-sft-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": "cfcamo/cfcamo-sft-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"
}
}
]
}
]
}'How to use cfcamo/cfcamo-sft-4b with Docker Model Runner:
docker model run hf.co/cfcamo/cfcamo-sft-4b
Cold-start checkpoint for CFCamo: Qwen3-VL-4B-Instruct fine-tuned on 1000 paired SFT rows (500 detect + 500 abstain, r=1:1) to teach the detect-or-abstain output schema. This is the init from which the RL stages (LoRA / Full FT) are trained; on its own it already abstains on target-absent counterfactuals but the paper-main numbers come from the RL checkpoints.
from transformers import AutoModelForImageTextToText, AutoProcessor
from PIL import Image
ckpt = "cfcamo/cfcamo-sft-4b"
processor = AutoProcessor.from_pretrained(ckpt)
model = AutoModelForImageTextToText.from_pretrained(
ckpt, torch_dtype="auto", device_map="auto",
).eval()
# (use the same detect-or-abstain prompt as cfcamo-rl-full — see that model card)
git clone https://github.com/suhang2000/CFCamo && cd CFCamo
pip install -e .
huggingface-cli download cfcamo/cfcamo-sft-4b --local-dir checkpoints/cfcamo-sft-4b
huggingface-cli download --repo-type dataset cfcamo/CF-COD --local-dir data/cfcod
# LoRA (single GPU) — paper-main LoRA checkpoint at step 252 (epsilon=0.5)
python -m verl.trainer.main config=configs/rl_lora.yaml
# Full fine-tuning (multi-GPU) — checkpoint at step 126 (epsilon=0.5)
python -m verl.trainer.main config=configs/rl_full.yaml
The two RL checkpoints are also released at cfcamo/cfcamo-rl-lora (LoRA adapter on top of this SFT base) and cfcamo/cfcamo-rl-full.
@article{li2026cfcamo,
title = {{CFCamo}: A Counterfactual Detect-or-Abstain Framework for Camouflaged Object Detection},
author = {Li, Suhang and Yoshie, Osamu and Ieiri, Yuya},
journal = {arXiv preprint arXiv:2606.11231},
year = {2026}
}