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-0.8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use prithivMLmods/ImageShield-MMCF-0.8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="prithivMLmods/ImageShield-MMCF-0.8B") 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-0.8B") model = AutoModelForMultimodalLM.from_pretrained("prithivMLmods/ImageShield-MMCF-0.8B", 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-0.8B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "prithivMLmods/ImageShield-MMCF-0.8B" # 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-0.8B", "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-0.8B
- SGLang
How to use prithivMLmods/ImageShield-MMCF-0.8B 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-0.8B" \ --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-0.8B", "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-0.8B" \ --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-0.8B", "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-0.8B with Docker Model Runner:
docker model run hf.co/prithivMLmods/ImageShield-MMCF-0.8B
Update README.md
Browse files
README.md
CHANGED
|
@@ -6,6 +6,158 @@ base_model:
|
|
| 6 |
- Qwen/Qwen3.5-0.8B
|
| 7 |
datasets:
|
| 8 |
- pr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ithivMLmods/ImageShield-Guardrail-Multimodal-20K
|
| 9 |
+
pipeline_tag: image-text-to-text
|
| 10 |
+
library_name: transformers
|
| 11 |
+
tags:
|
| 12 |
+
- text-generation-inference
|
| 13 |
---
|
| 14 |
|
| 15 |
+
# **ImageShield-MMCF-0.8B**
|
| 16 |
+
|
| 17 |
+
> **ImageShield-MMCF — Multimodal Content Filter** is a multimodal content-safety classifier built on top of **Qwen/Qwen3.5-0.8B** 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 **Non-Consensual Intimate Imagery (NCII)** and other potentially sensitive visual content.
|
| 18 |
+
|
| 19 |
+
> [!NOTE]
|
| 20 |
+
>
|
| 21 |
+
> **This model is an experimental release and may generate unexpected behaviors or reasoning artifacts in certain scenarios.**
|
| 22 |
+
|
| 23 |
+
> [!IMPORTANT]
|
| 24 |
+
> **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.
|
| 25 |
+
|
| 26 |
+
## **Key Highlights**
|
| 27 |
+
|
| 28 |
+
* **Qwen 3.5 Foundation**: Built on top of **Qwen/Qwen3.5-0.8B**.
|
| 29 |
+
* **Multimodal Content Filter**: Designed for visual content-safety classification.
|
| 30 |
+
* **28K Training Samples**: Trained on approximately **28,000 content-safety guardrail samples**.
|
| 31 |
+
* **Safe / Unsafe Classification**: Classifies visual content as either **Safe** or **Unsafe**.
|
| 32 |
+
* **NCII Detection**: Focused on identifying potentially **Non-Consensual Intimate Imagery (NCII)** and related sensitive visual content.
|
| 33 |
+
* **Zero-Tolerance Safety Classification**: Uses a conservative classification policy that favors safety when the content is ambiguous.
|
| 34 |
+
* **Structured Output**: Produces a machine-readable JSON response containing a caption, classification, and reasoning.
|
| 35 |
+
|
| 36 |
+
## **Standard Instruction**
|
| 37 |
+
|
| 38 |
+
```text
|
| 39 |
+
You are a strict, zero-tolerance parental control content-safety guardrail classifier for visual media.
|
| 40 |
+
|
| 41 |
+
Your role is minor protection: any media containing suggestive, revealing, sexually provocative, or explicit visual elements must be flagged as NSFW.
|
| 42 |
+
|
| 43 |
+
STRICT ZERO-TOLERANCE CLASSIFICATION RULES:
|
| 44 |
+
|
| 45 |
+
1. Nudity & Exposure: Any full or partial nudity, exposed breasts, cleavage, buttocks, groin, or visible pubic area MUST be classified as NSFW.
|
| 46 |
+
|
| 47 |
+
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.
|
| 48 |
+
|
| 49 |
+
3. Poses & Suggestiveness: Sexually suggestive poses, seductive modeling, cleavage-emphasizing framing, fetish content, or explicit erotic themes MUST be classified as NSFW.
|
| 50 |
+
|
| 51 |
+
4. Artwork & Animation: Anime nudes, ecchi, hentai, suggestive illustrations, or 2D/3D stylized erotica MUST be classified as NSFW.
|
| 52 |
+
|
| 53 |
+
5. Classification Threshold: When in doubt, err on the side of caution and classify the content as NSFW.
|
| 54 |
+
|
| 55 |
+
Output strictly valid JSON with no extra conversational text, commentary, or markdown formatting outside the JSON object:
|
| 56 |
+
|
| 57 |
+
{
|
| 58 |
+
"caption": "<Detailed, objective visual description of the subject, clothing, exposure, and pose>",
|
| 59 |
+
"is_nsfw": true | false,
|
| 60 |
+
"reason": "<Precise reason for classification based on clothing, exposure, or pose>",
|
| 61 |
+
"nsfw": 1 | 0,
|
| 62 |
+
"safe": 1 | 0
|
| 63 |
+
}
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
## **Quick Start with Transformers**
|
| 67 |
+
|
| 68 |
+
```bash
|
| 69 |
+
pip install transformers
|
| 70 |
+
pip install accelerate
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
```python
|
| 74 |
+
from transformers import Qwen3_5ForConditionalGeneration, AutoProcessor
|
| 75 |
+
import torch
|
| 76 |
+
|
| 77 |
+
model = Qwen3_5ForConditionalGeneration.from_pretrained(
|
| 78 |
+
"prithivMLmods/ImageShield-MMCF-0.8B",
|
| 79 |
+
torch_dtype="auto",
|
| 80 |
+
device_map="auto"
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
+
processor = AutoProcessor.from_pretrained(
|
| 84 |
+
"prithivMLmods/ImageShield-MMCF-0.8B"
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
messages = [
|
| 88 |
+
{
|
| 89 |
+
"role": "user",
|
| 90 |
+
"content": [
|
| 91 |
+
{
|
| 92 |
+
"type": "text",
|
| 93 |
+
"text": "Classify this image using the provided content-safety guardrail."
|
| 94 |
+
}
|
| 95 |
+
],
|
| 96 |
+
}
|
| 97 |
+
]
|
| 98 |
+
|
| 99 |
+
text = processor.apply_chat_template(
|
| 100 |
+
messages,
|
| 101 |
+
tokenize=False,
|
| 102 |
+
add_generation_prompt=True
|
| 103 |
+
)
|
| 104 |
+
|
| 105 |
+
inputs = processor(
|
| 106 |
+
text=[text],
|
| 107 |
+
padding=True,
|
| 108 |
+
return_tensors="pt"
|
| 109 |
+
).to("cuda")
|
| 110 |
+
|
| 111 |
+
generated_ids = model.generate(
|
| 112 |
+
**inputs,
|
| 113 |
+
max_new_tokens=256
|
| 114 |
+
)
|
| 115 |
+
|
| 116 |
+
output_text = processor.batch_decode(
|
| 117 |
+
[
|
| 118 |
+
out[len(inp):]
|
| 119 |
+
for inp, out in zip(inputs.input_ids, generated_ids)
|
| 120 |
+
],
|
| 121 |
+
skip_special_tokens=True,
|
| 122 |
+
clean_up_tokenization_spaces=False
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
+
print(output_text[0])
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
## **Training Details**
|
| 129 |
+
|
| 130 |
+
| Setting | Value |
|
| 131 |
+
| :------------------------- | :----------------------------------------- |
|
| 132 |
+
| **Base Model** | **Qwen/Qwen3.5-0.8B** |
|
| 133 |
+
| **Model Type** | **Multimodal Content-Safety Classifier** |
|
| 134 |
+
| **Training Samples** | Approximately **28,000** |
|
| 135 |
+
| **Training Objective** | Content-safety guardrail classification |
|
| 136 |
+
| **Primary Classification** | **Safe / Unsafe** |
|
| 137 |
+
| **Safety Focus** | **Non-Consensual Intimate Imagery (NCII)** |
|
| 138 |
+
| **Training Framework** | **TRL** |
|
| 139 |
+
|
| 140 |
+
## **Intended Use**
|
| 141 |
+
|
| 142 |
+
* **Content Safety Classification**: Classifying visual media as safe or unsafe.
|
| 143 |
+
* **NCII Detection**: Supporting research into automated detection of potentially non-consensual intimate imagery.
|
| 144 |
+
* **Parental Controls**: Building conservative visual content-safety filtering systems.
|
| 145 |
+
* **Content Moderation**: Supporting automated safety classification pipelines.
|
| 146 |
+
* **Multimodal Safety Research**: Evaluating content-safety behavior in multimodal language models.
|
| 147 |
+
* **Guardrail Development**: Researching structured safety classification and filtering workflows.
|
| 148 |
+
|
| 149 |
+
## **Limitations**
|
| 150 |
+
|
| 151 |
+
* **Experimental Model**: The model may produce incorrect or inconsistent classifications.
|
| 152 |
+
* **False Positives**: Benign content may occasionally be classified as unsafe due to the conservative classification threshold.
|
| 153 |
+
* **False Negatives**: Unsafe content may occasionally be missed.
|
| 154 |
+
* **Context Sensitivity**: Classification performance depends on image quality, visual context, and the provided instruction.
|
| 155 |
+
* **Automated Classification**: The model should not be treated as a definitive legal or safety determination.
|
| 156 |
+
|
| 157 |
+
## **Acknowledgements**
|
| 158 |
+
|
| 159 |
+
* **[Qwen/Qwen3.5-0.8B](https://huggingface.co/Qwen/Qwen3.5-0.8B)**: Base multimodal model used for this project.
|
| 160 |
+
|
| 161 |
+
* **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.
|
| 162 |
+
|
| 163 |
+
* **[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.
|