--- library_name: transformers tags: - text-generation-inference - VisionGuardrail - JSON - image-classification - content-safety - content-moderation - multimodal - safety-classifier - guardrail - visual-safety - multimodal-content-filter - mmcf license: apache-2.0 datasets: - prithivMLmods/ImageShield-Guardrail-Pro language: - en base_model: - Qwen/Qwen3.5-4B pipeline_tag: image-text-to-text --- ![4B](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/iefXN2AI9fjfwciQaxwjH.png) # **VisionGuardrail-4B** > **VisionGuardrail-4B** is a multimodal content-safety classifier based on **Qwen/Qwen3.5-4B** and trained on the **[ImageShield-Guardrail-Pro](https://huggingface.co/datasets/prithivMLmods/ImageShield-Guardrail-Pro)** content-safety guardrail dataset. 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. VisionGuardrail-4B excels at detecting **explicit and sensitive visual content**, with detailed analysis of **dress codes, clothing exposure, poses, framing, and different visual settings** to support conservative content-safety classification. > [!TIP] > hf.co/blog — [vision-guardrail-mini-blog](https://huggingface.co/blog/prithivMLmods/vision-guardrail-mini-blog) > [!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 **Qwen/Qwen3.5-4B**. * **Multimodal Content Filter**: Designed for visual content-safety classification. * **ImageShield-Guardrail-Pro Training**: Fine-tuned on the **prithivMLmods/ImageShield-Guardrail-Pro** content-safety guardrail dataset. * **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 material. * **Explicit & Sensitive Content Detection**: Excels at identifying explicit, revealing, provocative, and otherwise potentially sensitive visual content. * **Dress-Code Analysis**: Performs detailed analysis of clothing, dress codes, exposure, and revealing garments. * **Pose Analysis**: Analyzes body poses, positioning, framing, and potentially suggestive presentation. * **Context & Setting Analysis**: Considers different visual settings and contextual cues when determining content safety. * **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. Dress-Code Analysis: Carefully analyze clothing, coverage, transparency, exposure, and the overall dress code. Revealing or sexually provocative clothing MUST be classified as NSFW. 4. Poses & Suggestiveness: Sexually suggestive poses, seductive modeling, cleavage-emphasizing framing, fetish content, or explicit erotic themes MUST be classified as NSFW. 5. Context & Setting: Consider the visual setting, composition, framing, and contextual cues when evaluating potentially sensitive content. 6. Artwork & Animation: Anime nudes, ecchi, hentai, suggestive illustrations, or 2D/3D stylized erotica MUST be classified as NSFW. 7. Sensitive Visual Content: Explicit or highly suggestive visual content MUST be classified as NSFW even when presented in non-photorealistic or artistic formats. 8. 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": "", "is_nsfw": true | false, "reason": "", "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/VisionGuardrail-4B", torch_dtype="auto", device_map="auto" ) processor = AutoProcessor.from_pretrained( "prithivMLmods/VisionGuardrail-4B" ) 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]) ``` --- ## **Training Details** | Setting | Value | | :------------------------- | :------------------------------------------- | | **Base Model** | **Qwen/Qwen3.5-4B** | | **Model** | **VisionGuardrail-4B** | | **Model Type** | **Multimodal Content-Safety Classifier** | | **Training Dataset** | **prithivMLmods/ImageShield-Guardrail-Pro** | | **Training Objective** | **Content-safety guardrail classification** | | **Primary Classification** | **Safe / Unsafe** | | **Safety Focus** | **Not Safe for Work (NSFW) Sensual Content** | | **Visual Analysis** | **Dress Codes, Poses, Exposure & Settings** | | **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. * **Visual Safety Analysis**: Analyzing clothing, dress codes, poses, framing, and visual settings for content-safety signals. ## **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. * **Visual Ambiguity**: Clothing, poses, artistic styles, and contextual cues may sometimes be difficult to interpret accurately. * **Automated Classification**: The model should not be treated as a definitive legal or safety determination. ## **Acknowledgements** * **[Qwen/Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B)**: Base multimodal model used for this project. * **[ImageShield-Guardrail-Pro](https://huggingface.co/datasets/prithivMLmods/ImageShield-Guardrail-Pro)**: Content-safety guardrail dataset used for training VisionGuardrail-4B. * **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.