Image-Text-to-Text
Transformers
Safetensors
English
qwen3_5
text-generation-inference
JSON
image-classification
content-safety
content-moderation
multimodal
safety-classifier
guardrail
ncii-detection
visual-safety
qwen3.5
multimodal-content-filter
conversational
Instructions to use prithivMLmods/ImageShield-MMCF-2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use prithivMLmods/ImageShield-MMCF-2B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="prithivMLmods/ImageShield-MMCF-2B") 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("prithivMLmods/ImageShield-MMCF-2B") model = AutoModelForMultimodalLM.from_pretrained("prithivMLmods/ImageShield-MMCF-2B", 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 prithivMLmods/ImageShield-MMCF-2B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "prithivMLmods/ImageShield-MMCF-2B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "prithivMLmods/ImageShield-MMCF-2B", "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/prithivMLmods/ImageShield-MMCF-2B
- SGLang
How to use prithivMLmods/ImageShield-MMCF-2B 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 "prithivMLmods/ImageShield-MMCF-2B" \ --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": "prithivMLmods/ImageShield-MMCF-2B", "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 "prithivMLmods/ImageShield-MMCF-2B" \ --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": "prithivMLmods/ImageShield-MMCF-2B", "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 prithivMLmods/ImageShield-MMCF-2B with Docker Model Runner:
docker model run hf.co/prithivMLmods/ImageShield-MMCF-2B
File size: 12,229 Bytes
4c26253 0f1a6b9 736fd9a a483bd9 fbcf1ed 84a1bc7 4c26253 1d6eb79 72b4bfa 580aa25 1d2f1e1 3b75895 1d2f1e1 b6abf74 1d2f1e1 3b75895 1d2f1e1 3b75895 1d2f1e1 650c010 d587be7 3b75895 650c010 3b75895 d587be7 650c010 d587be7 650c010 d587be7 650c010 d587be7 3b75895 d587be7 650c010 d587be7 3b75895 d587be7 2a2340f d587be7 650c010 d587be7 3b75895 d587be7 650c010 d587be7 3b75895 d587be7 650c010 3b75895 d587be7 650c010 d587be7 650c010 d587be7 650c010 1d2f1e1 3b75895 1d2f1e1 3b75895 1d2f1e1 3b75895 1d2f1e1 3b75895 1d2f1e1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | ---
license: apache-2.0
base_model:
- Qwen/Qwen3.5-2B
datasets:
- prithivMLmods/ImageShield-Guardrail-Multimodal-20K
language:
- en
pipeline_tag: image-text-to-text
library_name: transformers
tags:
- text-generation-inference
- JSON
- image-classification
- content-safety
- content-moderation
- multimodal
- safety-classifier
- guardrail
- ncii-detection
- visual-safety
- qwen3.5
- multimodal-content-filter
---

# **ImageShield-MMCF-2B**
> **ImageShield-MMCF — Multimodal Content Filter** is a multimodal content-safety classifier built on top of **Qwen/Qwen3.5-2B** and trained on approximately **28,000 content-safety guardrail samples**. The model is designed to classify visual content as **Safe** or **Unsafe**, with a particular focus on detecting **Not Safe for Work (NSFW) sensual content** and other potentially sensitive visual content.
<a href="#example-cards">
<img src="https://img.shields.io/badge/View-Example_Cards-blue?style=for-the-badge" alt="Jump to Examples" />
</a>
> [!NOTE]
> **This model is an experimental release and may generate unexpected behaviors or reasoning artifacts in certain scenarios.**
> [!IMPORTANT]
> **This model is intended for research and content-safety classification only.** Any outputs generated by this model are the sole responsibility of the user. The authors and hosting platform disclaim all liability for generated content. Users must ensure safe, ethical, and lawful usage.
## **Key Highlights**
* **Qwen 3.5 Foundation**: Built on top of **Qwen/Qwen3.5-2B**.
* **Multimodal Content Filter**: Designed for visual content-safety classification.
* **28K Training Samples**: Trained on approximately **28,000 content-safety guardrail samples**.
* **Safe / Unsafe Classification**: Classifies visual content as either **Safe** or **Unsafe**.
* **NSFW Sensual Content Detection**: Focused on identifying potentially **Not Safe for Work (NSFW) sensual content** and related sensitive visual content.
* **Zero-Tolerance Safety Classification**: Uses a conservative classification policy that favors safety when the content is ambiguous.
* **Structured Output**: Produces a machine-readable JSON response containing a caption, classification, and reasoning.
## **Standard Instruction**
```text
You are a strict, zero-tolerance parental control content-safety guardrail classifier for visual media.
Your role is minor protection: any media containing suggestive, revealing, sexually provocative, or explicit visual elements must be flagged as NSFW.
STRICT ZERO-TOLERANCE CLASSIFICATION RULES:
1. Nudity & Exposure: Any full or partial nudity, exposed breasts, cleavage, buttocks, groin, or visible pubic area MUST be classified as NSFW.
2. Underwear & Swimwear: Thongs, G-strings, micro-bikinis, skimpy or revealing swimwear, bras, panties, lingerie, see-through clothing, or unbuttoned tops revealing undergarments or bare torsos MUST be classified as NSFW.
3. Poses & Suggestiveness: Sexually suggestive poses, seductive modeling, cleavage-emphasizing framing, fetish content, or explicit erotic themes MUST be classified as NSFW.
4. Artwork & Animation: Anime nudes, ecchi, hentai, suggestive illustrations, or 2D/3D stylized erotica MUST be classified as NSFW.
5. Classification Threshold: When in doubt, err on the side of caution and classify the content as NSFW.
Output strictly valid JSON with no extra conversational text, commentary, or markdown formatting outside the JSON object:
{
"caption": "<Detailed, objective visual description of the subject, clothing, exposure, and pose>",
"is_nsfw": true | false,
"reason": "<Precise reason for classification based on clothing, exposure, or pose>",
"nsfw": 1 | 0,
"safe": 1 | 0
}
```
## **Quick Start with Transformers**
```bash
pip install transformers
pip install accelerate
```
```python
from transformers import Qwen3_5ForConditionalGeneration, AutoProcessor
import torch
model = Qwen3_5ForConditionalGeneration.from_pretrained(
"prithivMLmods/ImageShield-MMCF-2B",
torch_dtype="auto",
device_map="auto"
)
processor = AutoProcessor.from_pretrained(
"prithivMLmods/ImageShield-MMCF-2B"
)
messages = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Classify this image using the provided content-safety guardrail."
}
],
}
]
text = processor.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
inputs = processor(
text=[text],
padding=True,
return_tensors="pt"
).to("cuda")
generated_ids = model.generate(
**inputs,
max_new_tokens=256
)
output_text = processor.batch_decode(
[
out[len(inp):]
for inp, out in zip(inputs.input_ids, generated_ids)
],
skip_special_tokens=True,
clean_up_tokenization_spaces=False
)
print(output_text[0])
```
---
## **Example Cards**
<div style="background-color: #000000; font-family: 'Courier New', Courier, monospace; color: #FFFFFF; padding: 24px; border-radius: 12px; border: 1px solid #333333; max-width: 800px; margin: 0 auto;">
<!-- Card 1 -->
<div style="margin-bottom: 32px;">
<div style="border-radius: 8px; overflow: hidden; margin-bottom: 16px; border: 1px solid #222;">
<img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/UnSXkoCSNmeiGF0OAGMO5.jpeg" alt="Safe Image 1" style="width: 100%; height: auto; display: block;">
</div>
<pre style="background-color: #0a0a0a; padding: 16px; border-radius: 8px; border: 1px solid #222; color: #e0e0e0; font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; margin: 0;">
{
"caption": "Two female tennis players in white athletic wear are shaking hands on a tennis court, with a net between them. In the background, a woman in a blue uniform stands near a green wall, and a man in a navy blazer and white trousers observes.",
"is_nsfw": <span style="color: #4ade80;">false</span>,
"reason": "The image depicts a standard sports scene featuring two female tennis players in professional attire (white skirts and tops) engaging in a handshake. The setting includes a tennis court, a net, and a line judge or official in the background. There is no evidence of nudity, revealing swimwear, suggestive poses, or any elements that would indicate an NSFW classification.",
"nsfw": <span style="color: #4ade80;">0</span>,
"safe": <span style="color: #4ade80;">1</span>
}</pre>
</div>
<!-- Thin Line Bar -->
<hr style="border: 0; border-top: 1px solid #333333; margin: 0 0 32px 0;">
<!-- Card 2 (NSFW - Blurred) -->
<div style="margin-bottom: 32px;">
<div style="border-radius: 8px; overflow: hidden; margin-bottom: 16px; border: 1px solid #222; position: relative;">
<img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/3kmNwpo0uf66ZgnKrs2Kb.png" alt="NSFW Image 2" style="width: 100%; height: auto; display: block; filter: blur(30px) saturate(0.8); transform: scale(1.1);">
</div>
<pre style="background-color: #0a0a0a; padding: 16px; border-radius: 8px; border: 1px solid #222; color: #e0e0e0; font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; margin: 0;">
{
"caption": "A close-up profile shot of a woman with tanned skin, wearing a yellow and white patterned fabric draped over her lower body. She is holding the fabric up to reveal her bare buttocks and hip area. Her upper body is largely exposed, showing cleavage and a bare chest, while her dark hair is styled loosely.",
"is_nsfw": <span style="color: #4ade80;">true</span>,
"reason": "The image is classified as NSFW due to significant nudity, substantial skin exposure, and a revealing presentation.",
"nsfw": <span style="color: #4ade80;">1</span>,
"safe": <span style="color: #4ade80;">0</span>
}</pre>
</div>
<!-- Thin Line Bar -->
<hr style="border: 0; border-top: 1px solid #333333; margin: 0 0 32px 0;">
<!-- Card 3 -->
<div>
<div style="border-radius: 8px; overflow: hidden; margin-bottom: 16px; border: 1px solid #222;">
<img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/ZwuWL28H1PlGcv70X4Dbt.jpeg" alt="Safe Image 3" style="width: 100%; height: auto; display: block;">
</div>
<pre style="background-color: #0a0a0a; padding: 16px; border-radius: 8px; border: 1px solid #222; color: #e0e0e0; font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; margin: 0;">
{
"caption": "A young girl with blonde hair, wearing a blue soccer jersey and black shorts, is captured mid-air kicking a white soccer ball on a grassy hill. She is wearing white socks and cleats. The background is a clear, solid blue sky.",
"is_nsfw": <span style="color: #4ade80;">false</span>,
"reason": "The image depicts an active sports scene featuring a child playing soccer. The subject is fully clothed in standard athletic gear (jersey, shorts, socks, cleats) and is engaged in a dynamic action pose. There is no evidence of nudity, revealing swimwear, suggestive poses, or any elements that would indicate NSFW content.",
"nsfw": <span style="color: #4ade80;">0</span>,
"safe": <span style="color: #4ade80;">1</span>
}</pre>
</div>
</div>
---
## **Training Details**
| Setting | Value |
| :------------------------- | :------------------------------------------- |
| **Base Model** | **Qwen/Qwen3.5-2B** |
| **Model Type** | **Multimodal Content-Safety Classifier** |
| **Training Samples** | Approximately **28,000** |
| **Training Objective** | Content-safety guardrail classification |
| **Primary Classification** | **Safe / Unsafe** |
| **Safety Focus** | **Not Safe for Work (NSFW) Sensual Content** |
| **Training Framework** | **TRL** |
## **Intended Use**
* **Content Safety Classification**: Classifying visual media as safe or unsafe.
* **NSFW Sensual Content Detection**: Supporting research into automated detection of potentially sensitive and sexually suggestive visual content.
* **Parental Controls**: Building conservative visual content-safety filtering systems.
* **Content Moderation**: Supporting automated safety classification pipelines.
* **Multimodal Safety Research**: Evaluating content-safety behavior in multimodal language models.
* **Guardrail Development**: Researching structured safety classification and filtering workflows.
## **Limitations**
* **Experimental Model**: The model may produce incorrect or inconsistent classifications.
* **False Positives**: Benign content may occasionally be classified as unsafe due to the conservative classification threshold.
* **False Negatives**: Unsafe content may occasionally be missed.
* **Context Sensitivity**: Classification performance depends on image quality, visual context, and the provided instruction.
* **Conservative Policy**: The model intentionally uses a strict classification threshold and may flag content that would not be considered NSFW under less restrictive moderation policies.
* **Automated Classification**: The model should not be treated as a definitive legal or safety determination.
## **Acknowledgements**
* **[Qwen/Qwen3.5-2B](https://huggingface.co/Qwen/Qwen3.5-2B)**: Base multimodal model used for this project.
* **TRL – [Transformers Reinforcement Learning](https://huggingface.co/docs/trl/en/index)**: TRL is a full-stack library providing tools to train transformer language models with methods including Supervised Fine-Tuning (SFT), Group Relative Policy Optimization (GRPO), Direct Preference Optimization (DPO), Reward Modeling, and more.
* **[Transformers](https://huggingface.co/docs/transformers/en/index)**: Transformers provides state-of-the-art machine learning models for text, computer vision, audio, video, and multimodal tasks, supporting both inference and training. |