Views
No views yet
| Detail | Value |
|---|---|
| Base Model | Qwen2.5-VL-7B-Instruct |
| Training Method | GRPO (Group Relative Policy Optimization) |
| Training Data | AIML-TUDA/LlavaGuard (train split) |
1from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor
2from qwen_vl_utils import process_vision_info
3
4model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
5 "tyodd/SafeGuard-VL-RL",
6 torch_dtype="auto",
7 device_map="auto",
8)
9processor = AutoProcessor.from_pretrained("tyodd/SafeGuard-VL-RL")
10
11# Example: Safety evaluation with a custom policy
12policy = """
13"""
14
15messages = [
16 {
17 "role": "user",
18 "content": [
19 {"type": "image", "image": "path/to/image.jpg"},
20 {"type": "text", "text": f"Based on the following safety policy, determine if this image is safe or unsafe.\n\nPolicy:\n{policy}\n\nProvide your reasoning and final judgment (Safe/Unsafe)."},
21 ],
22 }
23]
24
25text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
26image_inputs, video_inputs = process_vision_info(messages)
27inputs = processor(
28 text=[text],
29 images=image_inputs,
30 videos=video_inputs,
31 padding=True,
32 return_tensors="pt",
33).to(model.device)
34
35generated_ids = model.generate(**inputs, max_new_tokens=512)
36generated_ids_trimmed = [
37 out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
38]
39output_text = processor.batch_decode(
40 generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
41)
42print(output_text[0])1@inproceedings{piao2026towards,
2 title={Towards policy-adaptive image guardrail: Benchmark and method},
3 author={Piao, Caiyong and Yan, Zhiyuan and Xu, Haoming and Zhao, Yunzhen and Lin, Kaiqing and Xu, Feiyang and Zhou, Shuigeng},
4 booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
5 pages={16614--16623},
6 year={2026}
7}