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
Update README.md
Browse files
README.md
CHANGED
|
@@ -26,7 +26,7 @@ tags:
|
|
| 26 |
|
| 27 |
# **ImageShield-MMCF-2B**
|
| 28 |
|
| 29 |
-
> **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 **
|
| 30 |
|
| 31 |
<a href="#example-cards">
|
| 32 |
<img src="https://img.shields.io/badge/View-Example_Cards-blue?style=for-the-badge" alt="Jump to Examples" />
|
|
@@ -36,7 +36,7 @@ tags:
|
|
| 36 |
> **This model is an experimental release and may generate unexpected behaviors or reasoning artifacts in certain scenarios.**
|
| 37 |
|
| 38 |
> [!IMPORTANT]
|
| 39 |
-
> **This model is intended for research and content
|
| 40 |
|
| 41 |
## **Key Highlights**
|
| 42 |
|
|
@@ -44,7 +44,7 @@ tags:
|
|
| 44 |
* **Multimodal Content Filter**: Designed for visual content-safety classification.
|
| 45 |
* **28K Training Samples**: Trained on approximately **28,000 content-safety guardrail samples**.
|
| 46 |
* **Safe / Unsafe Classification**: Classifies visual content as either **Safe** or **Unsafe**.
|
| 47 |
-
* **
|
| 48 |
* **Zero-Tolerance Safety Classification**: Uses a conservative classification policy that favors safety when the content is ambiguous.
|
| 49 |
* **Structured Output**: Produces a machine-readable JSON response containing a caption, classification, and reasoning.
|
| 50 |
|
|
@@ -145,8 +145,9 @@ print(output_text[0])
|
|
| 145 |
## **Example Cards**
|
| 146 |
|
| 147 |
<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;">
|
| 148 |
-
|
| 149 |
<!-- Card 1 -->
|
|
|
|
| 150 |
<div style="margin-bottom: 32px;">
|
| 151 |
<div style="border-radius: 8px; overflow: hidden; margin-bottom: 16px; border: 1px solid #222;">
|
| 152 |
<img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/UnSXkoCSNmeiGF0OAGMO5.jpeg" alt="Safe Image 1" style="width: 100%; height: auto; display: block;">
|
|
@@ -162,9 +163,11 @@ print(output_text[0])
|
|
| 162 |
</div>
|
| 163 |
|
| 164 |
<!-- Thin Line Bar -->
|
|
|
|
| 165 |
<hr style="border: 0; border-top: 1px solid #333333; margin: 0 0 32px 0;">
|
| 166 |
|
| 167 |
<!-- Card 2 (NSFW - Blurred) -->
|
|
|
|
| 168 |
<div style="margin-bottom: 32px;">
|
| 169 |
<div style="border-radius: 8px; overflow: hidden; margin-bottom: 16px; border: 1px solid #222; position: relative;">
|
| 170 |
<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);">
|
|
@@ -173,16 +176,18 @@ print(output_text[0])
|
|
| 173 |
{
|
| 174 |
"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.",
|
| 175 |
"is_nsfw": <span style="color: #4ade80;">true</span>,
|
| 176 |
-
"reason": "The image
|
| 177 |
"nsfw": <span style="color: #4ade80;">1</span>,
|
| 178 |
"safe": <span style="color: #4ade80;">0</span>
|
| 179 |
}</pre>
|
| 180 |
</div>
|
| 181 |
|
| 182 |
<!-- Thin Line Bar -->
|
|
|
|
| 183 |
<hr style="border: 0; border-top: 1px solid #333333; margin: 0 0 32px 0;">
|
| 184 |
|
| 185 |
<!-- Card 3 -->
|
|
|
|
| 186 |
<div>
|
| 187 |
<div style="border-radius: 8px; overflow: hidden; margin-bottom: 16px; border: 1px solid #222;">
|
| 188 |
<img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/ZwuWL28H1PlGcv70X4Dbt.jpeg" alt="Safe Image 3" style="width: 100%; height: auto; display: block;">
|
|
@@ -203,20 +208,20 @@ print(output_text[0])
|
|
| 203 |
|
| 204 |
## **Training Details**
|
| 205 |
|
| 206 |
-
| Setting | Value
|
| 207 |
-
| :------------------------- | :----------------------------------------- |
|
| 208 |
-
| **Base Model** | **Qwen/Qwen3.5-2B**
|
| 209 |
-
| **Model Type** | **Multimodal Content-Safety Classifier**
|
| 210 |
-
| **Training Samples** | Approximately **28,000**
|
| 211 |
-
| **Training Objective** | Content-safety guardrail classification
|
| 212 |
-
| **Primary Classification** | **Safe / Unsafe**
|
| 213 |
-
| **Safety Focus** | **
|
| 214 |
-
| **Training Framework** | **TRL**
|
| 215 |
|
| 216 |
## **Intended Use**
|
| 217 |
|
| 218 |
* **Content Safety Classification**: Classifying visual media as safe or unsafe.
|
| 219 |
-
* **
|
| 220 |
* **Parental Controls**: Building conservative visual content-safety filtering systems.
|
| 221 |
* **Content Moderation**: Supporting automated safety classification pipelines.
|
| 222 |
* **Multimodal Safety Research**: Evaluating content-safety behavior in multimodal language models.
|
|
@@ -228,6 +233,7 @@ print(output_text[0])
|
|
| 228 |
* **False Positives**: Benign content may occasionally be classified as unsafe due to the conservative classification threshold.
|
| 229 |
* **False Negatives**: Unsafe content may occasionally be missed.
|
| 230 |
* **Context Sensitivity**: Classification performance depends on image quality, visual context, and the provided instruction.
|
|
|
|
| 231 |
* **Automated Classification**: The model should not be treated as a definitive legal or safety determination.
|
| 232 |
|
| 233 |
## **Acknowledgements**
|
|
@@ -235,5 +241,5 @@ print(output_text[0])
|
|
| 235 |
* **[Qwen/Qwen3.5-2B](https://huggingface.co/Qwen/Qwen3.5-2B)**: Base multimodal model used for this project.
|
| 236 |
|
| 237 |
* **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.
|
| 238 |
-
|
| 239 |
* **[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.
|
|
|
|
| 26 |
|
| 27 |
# **ImageShield-MMCF-2B**
|
| 28 |
|
| 29 |
+
> **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.
|
| 30 |
|
| 31 |
<a href="#example-cards">
|
| 32 |
<img src="https://img.shields.io/badge/View-Example_Cards-blue?style=for-the-badge" alt="Jump to Examples" />
|
|
|
|
| 36 |
> **This model is an experimental release and may generate unexpected behaviors or reasoning artifacts in certain scenarios.**
|
| 37 |
|
| 38 |
> [!IMPORTANT]
|
| 39 |
+
> **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.
|
| 40 |
|
| 41 |
## **Key Highlights**
|
| 42 |
|
|
|
|
| 44 |
* **Multimodal Content Filter**: Designed for visual content-safety classification.
|
| 45 |
* **28K Training Samples**: Trained on approximately **28,000 content-safety guardrail samples**.
|
| 46 |
* **Safe / Unsafe Classification**: Classifies visual content as either **Safe** or **Unsafe**.
|
| 47 |
+
* **NSFW Sensual Content Detection**: Focused on identifying potentially **Not Safe for Work (NSFW) sensual content** and related sensitive visual content.
|
| 48 |
* **Zero-Tolerance Safety Classification**: Uses a conservative classification policy that favors safety when the content is ambiguous.
|
| 49 |
* **Structured Output**: Produces a machine-readable JSON response containing a caption, classification, and reasoning.
|
| 50 |
|
|
|
|
| 145 |
## **Example Cards**
|
| 146 |
|
| 147 |
<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;">
|
| 148 |
+
|
| 149 |
<!-- Card 1 -->
|
| 150 |
+
|
| 151 |
<div style="margin-bottom: 32px;">
|
| 152 |
<div style="border-radius: 8px; overflow: hidden; margin-bottom: 16px; border: 1px solid #222;">
|
| 153 |
<img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/UnSXkoCSNmeiGF0OAGMO5.jpeg" alt="Safe Image 1" style="width: 100%; height: auto; display: block;">
|
|
|
|
| 163 |
</div>
|
| 164 |
|
| 165 |
<!-- Thin Line Bar -->
|
| 166 |
+
|
| 167 |
<hr style="border: 0; border-top: 1px solid #333333; margin: 0 0 32px 0;">
|
| 168 |
|
| 169 |
<!-- Card 2 (NSFW - Blurred) -->
|
| 170 |
+
|
| 171 |
<div style="margin-bottom: 32px;">
|
| 172 |
<div style="border-radius: 8px; overflow: hidden; margin-bottom: 16px; border: 1px solid #222; position: relative;">
|
| 173 |
<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);">
|
|
|
|
| 176 |
{
|
| 177 |
"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.",
|
| 178 |
"is_nsfw": <span style="color: #4ade80;">true</span>,
|
| 179 |
+
"reason": "The image is classified as NSFW due to significant nudity, substantial skin exposure, and a revealing presentation.",
|
| 180 |
"nsfw": <span style="color: #4ade80;">1</span>,
|
| 181 |
"safe": <span style="color: #4ade80;">0</span>
|
| 182 |
}</pre>
|
| 183 |
</div>
|
| 184 |
|
| 185 |
<!-- Thin Line Bar -->
|
| 186 |
+
|
| 187 |
<hr style="border: 0; border-top: 1px solid #333333; margin: 0 0 32px 0;">
|
| 188 |
|
| 189 |
<!-- Card 3 -->
|
| 190 |
+
|
| 191 |
<div>
|
| 192 |
<div style="border-radius: 8px; overflow: hidden; margin-bottom: 16px; border: 1px solid #222;">
|
| 193 |
<img src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/ZwuWL28H1PlGcv70X4Dbt.jpeg" alt="Safe Image 3" style="width: 100%; height: auto; display: block;">
|
|
|
|
| 208 |
|
| 209 |
## **Training Details**
|
| 210 |
|
| 211 |
+
| Setting | Value |
|
| 212 |
+
| :------------------------- | :------------------------------------------- |
|
| 213 |
+
| **Base Model** | **Qwen/Qwen3.5-2B** |
|
| 214 |
+
| **Model Type** | **Multimodal Content-Safety Classifier** |
|
| 215 |
+
| **Training Samples** | Approximately **28,000** |
|
| 216 |
+
| **Training Objective** | Content-safety guardrail classification |
|
| 217 |
+
| **Primary Classification** | **Safe / Unsafe** |
|
| 218 |
+
| **Safety Focus** | **Not Safe for Work (NSFW) Sensual Content** |
|
| 219 |
+
| **Training Framework** | **TRL** |
|
| 220 |
|
| 221 |
## **Intended Use**
|
| 222 |
|
| 223 |
* **Content Safety Classification**: Classifying visual media as safe or unsafe.
|
| 224 |
+
* **NSFW Sensual Content Detection**: Supporting research into automated detection of potentially sensitive and sexually suggestive visual content.
|
| 225 |
* **Parental Controls**: Building conservative visual content-safety filtering systems.
|
| 226 |
* **Content Moderation**: Supporting automated safety classification pipelines.
|
| 227 |
* **Multimodal Safety Research**: Evaluating content-safety behavior in multimodal language models.
|
|
|
|
| 233 |
* **False Positives**: Benign content may occasionally be classified as unsafe due to the conservative classification threshold.
|
| 234 |
* **False Negatives**: Unsafe content may occasionally be missed.
|
| 235 |
* **Context Sensitivity**: Classification performance depends on image quality, visual context, and the provided instruction.
|
| 236 |
+
* **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.
|
| 237 |
* **Automated Classification**: The model should not be treated as a definitive legal or safety determination.
|
| 238 |
|
| 239 |
## **Acknowledgements**
|
|
|
|
| 241 |
* **[Qwen/Qwen3.5-2B](https://huggingface.co/Qwen/Qwen3.5-2B)**: Base multimodal model used for this project.
|
| 242 |
|
| 243 |
* **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.
|
| 244 |
+
|
| 245 |
* **[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.
|