prithivMLmods commited on
Commit
1b2aa6a
·
verified ·
1 Parent(s): d7acb44

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +185 -1
README.md CHANGED
@@ -2,4 +2,188 @@
2
  license: apache-2.0
3
  base_model:
4
  - Qwen/Qwen3.5-4B
5
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: apache-2.0
3
  base_model:
4
  - Qwen/Qwen3.5-4B
5
+ ---
6
+
7
+ <div style="font-family: 'Ubuntu', 'Segoe UI', Roboto, sans-serif; background-color: #000000; color: #FFFFFF; padding: 30px; border-radius: 12px; line-height: 1.6;">
8
+
9
+ <h1 style="color: #FFFFFF; font-weight: 700; font-size: 28px; border-bottom: 1px solid #333; padding-bottom: 10px; margin-top: 0;">VisionGuardrail-4B</h1>
10
+
11
+ <p style="font-size: 16px;">
12
+ <b style="color: #FFFFFF;">VisionGuardrail-4B</b> is a multimodal content-safety classifier based on <b style="color: #FFFFFF;">Qwen/Qwen3.5-4B</b> and trained on the <a href="https://huggingface.co/datasets/prithivMLmods/ImageShield-Guardrail-Pro" style="color: #FF4500; text-decoration: none;">prithivMLmods/ImageShield-Guardrail-Pro</a> content-safety guardrail dataset. The model is designed to classify visual content as <b style="color: #FFFFFF;">Safe</b> or <b style="color: #FFFFFF;">Unsafe</b>, with a particular focus on detecting <b style="color: #FFFFFF;">Not Safe for Work (NSFW) sensual content</b> and other potentially sensitive visual content. VisionGuardrail-4B excels at detecting <b style="color: #FFFFFF;">explicit and sensitive visual content</b>, with detailed analysis of <b style="color: #FFFFFF;">dress codes, clothing exposure, poses, framing, and different visual settings</b> to support conservative content-safety classification.
13
+ </p>
14
+
15
+ <div style="background-color: #111; border: 1px solid #333; border-left: 4px solid #FF4500; padding: 15px; border-radius: 4px; margin: 20px 0; color: #FFFFFF;">
16
+ This model is an experimental release and may generate unexpected behaviors or reasoning artifacts in certain scenarios. <b style="color: #FFFFFF;">This model is intended for research and content-safety classification only.</b> 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.
17
+ </div>
18
+
19
+ <h2 style="color: #FFFFFF; font-weight: 700; font-size: 22px; margin-top: 30px; border-bottom: 1px solid #333; padding-bottom: 5px;">Key Highlights</h2>
20
+ <ul style="list-style-type: none; padding-left: 0; color: #FFFFFF; font-size: 15px;">
21
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Qwen 3.5 Foundation</b>: Built on <b style="color: #FFFFFF;">Qwen/Qwen3.5-4B</b>.</li>
22
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Multimodal Content Filter</b>: Designed for visual content-safety classification.</li>
23
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">ImageShield-Guardrail-Pro Training</b>: Fine-tuned on the <b style="color: #FFFFFF;">prithivMLmods/ImageShield-Guardrail-Pro</b> content-safety guardrail dataset.</li>
24
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Safe / Unsafe Classification</b>: Classifies visual content as either <b style="color: #FFFFFF;">Safe</b> or <b style="color: #FFFFFF;">Unsafe</b>.</li>
25
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">NSFW Sensual Content Detection</b>: Focused on identifying potentially <b style="color: #FFFFFF;">Not Safe for Work (NSFW) sensual content</b> and related sensitive visual material.</li>
26
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Explicit & Sensitive Content Detection</b>: Excels at identifying explicit, revealing, provocative, and otherwise potentially sensitive visual content.</li>
27
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Dress-Code Analysis</b>: Performs detailed analysis of clothing, dress codes, exposure, and revealing garments.</li>
28
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Pose Analysis</b>: Analyzes body poses, positioning, framing, and potentially suggestive presentation.</li>
29
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Context & Setting Analysis</b>: Considers different visual settings and contextual cues when determining content safety.</li>
30
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Zero-Tolerance Safety Classification</b>: Uses a conservative classification policy that favors safety when the content is ambiguous.</li>
31
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Structured Output</b>: Produces a machine-readable JSON response containing a caption, classification, and reasoning.</li>
32
+ </ul>
33
+
34
+ <h2 style="color: #FFFFFF; font-weight: 700; font-size: 22px; margin-top: 30px; border-bottom: 1px solid #333; padding-bottom: 5px;">Standard Instruction</h2>
35
+ <div style="position: relative; background-color: #111; border: 1px solid #333; border-radius: 4px; margin: 15px 0;">
36
+ <button style="position: absolute; top: 8px; right: 8px; background-color: #333; color: #FFF; border: none; padding: 4px 8px; border-radius: 3px; cursor: pointer; font-family: 'Ubuntu', sans-serif; font-size: 12px;" onclick="copyCode(this)">Copy</button>
37
+ <pre style="margin: 0; padding: 15px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;"><code style="color: #FFFFFF; font-family: 'Ubuntu Mono', monospace; font-size: 14px;">You are a strict, zero-tolerance parental control content-safety guardrail classifier for visual media.
38
+
39
+ Your role is minor protection: any media containing suggestive, revealing, sexually provocative, or explicit visual elements must be flagged as NSFW.
40
+
41
+ STRICT ZERO-TOLERANCE CLASSIFICATION RULES:
42
+
43
+ 1. Nudity & Exposure: Any full or partial nudity, exposed breasts, cleavage, buttocks, groin, or visible pubic area MUST be classified as NSFW.
44
+
45
+ 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.
46
+
47
+ 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.
48
+
49
+ 4. Poses & Suggestiveness: Sexually suggestive poses, seductive modeling, cleavage-emphasizing framing, fetish content, or explicit erotic themes MUST be classified as NSFW.
50
+
51
+ 5. Context & Setting: Consider the visual setting, composition, framing, and contextual cues when evaluating potentially sensitive content.
52
+
53
+ 6. Artwork & Animation: Anime nudes, ecchi, hentai, suggestive illustrations, or 2D/3D stylized erotica MUST be classified as NSFW.
54
+
55
+ 7. Sensitive Visual Content: Explicit or highly suggestive visual content MUST be classified as NSFW even when presented in non-photorealistic or artistic formats.
56
+
57
+ 8. Classification Threshold: When in doubt, err on the side of caution and classify the content as NSFW.
58
+
59
+ Output strictly valid JSON with no extra conversational text, commentary, or markdown formatting outside the JSON object:
60
+
61
+ {
62
+ "caption": "<Detailed, objective visual description of the subject, clothing, exposure, pose, and setting>",
63
+ "is_nsfw": true | false,
64
+ "reason": "<Precise reason for classification based on clothing, exposure, pose, context, or other visual cues>",
65
+ "nsfw": 1 | 0,
66
+ "safe": 1 | 0
67
+ }</code></pre>
68
+ </div>
69
+
70
+ <h2 style="color: #FFFFFF; font-weight: 700; font-size: 22px; margin-top: 30px; border-bottom: 1px solid #333; padding-bottom: 5px;">Quick Start with Transformers</h2>
71
+ <div style="position: relative; background-color: #111; border: 1px solid #333; border-radius: 4px; margin: 15px 0;">
72
+ <button style="position: absolute; top: 8px; right: 8px; background-color: #333; color: #FFF; border: none; padding: 4px 8px; border-radius: 3px; cursor: pointer; font-family: 'Ubuntu', sans-serif; font-size: 12px;" onclick="copyCode(this)">Copy</button>
73
+ <pre style="margin: 0; padding: 15px; overflow-x: auto;"><code style="color: #FFFFFF; font-family: 'Ubuntu Mono', monospace; font-size: 14px;">pip install transformers
74
+ pip install accelerate</code></pre>
75
+ </div>
76
+
77
+ <div style="position: relative; background-color: #111; border: 1px solid #333; border-radius: 4px; margin: 15px 0;">
78
+ <button style="position: absolute; top: 8px; right: 8px; background-color: #333; color: #FFF; border: none; padding: 4px 8px; border-radius: 3px; cursor: pointer; font-family: 'Ubuntu', sans-serif; font-size: 12px;" onclick="copyCode(this)">Copy</button>
79
+ <pre style="margin: 0; padding: 15px; overflow-x: auto;"><code style="color: #FFFFFF; font-family: 'Ubuntu Mono', monospace; font-size: 14px;">from transformers import Qwen3_5ForConditionalGeneration, AutoProcessor
80
+ import torch
81
+
82
+ model = Qwen3_5ForConditionalGeneration.from_pretrained(
83
+ "prithivMLmods/VisionGuardrail-4B",
84
+ torch_dtype="auto",
85
+ device_map="auto"
86
+ )
87
+
88
+ processor = AutoProcessor.from_pretrained(
89
+ "prithivMLmods/VisionGuardrail-4B"
90
+ )
91
+
92
+ messages = [
93
+ {
94
+ "role": "user",
95
+ "content": [
96
+ {
97
+ "type": "text",
98
+ "text": "Classify this image using the provided content-safety guardrail."
99
+ }
100
+ ],
101
+ }
102
+ ]
103
+
104
+ text = processor.apply_chat_template(
105
+ messages,
106
+ tokenize=False,
107
+ add_generation_prompt=True
108
+ )
109
+
110
+ inputs = processor(
111
+ text=[text],
112
+ padding=True,
113
+ return_tensors="pt"
114
+ ).to("cuda")
115
+
116
+ generated_ids = model.generate(
117
+ **inputs,
118
+ max_new_tokens=256
119
+ )
120
+
121
+ output_text = processor.batch_decode(
122
+ [
123
+ out[len(inp):]
124
+ for inp, out in zip(inputs.input_ids, generated_ids)
125
+ ],
126
+ skip_special_tokens=True,
127
+ clean_up_tokenization_spaces=False
128
+ )
129
+
130
+ print(output_text[0])</code></pre>
131
+ </div>
132
+
133
+ <hr style="border: 0; border-top: 1px solid #333; margin: 30px 0;">
134
+
135
+ <h2 style="color: #FFFFFF; font-weight: 700; font-size: 22px; margin-top: 30px; border-bottom: 1px solid #333; padding-bottom: 5px;">Training Details</h2>
136
+ <table style="width: 100%; border-collapse: collapse; margin: 15px 0; font-size: 14px; color: #FFFFFF;">
137
+ <tbody>
138
+ <tr style="border-bottom: 1px solid #333;"><td style="padding: 10px; font-weight: bold; width: 35%;">Base Model</td><td style="padding: 10px;"><b style="color: #FFFFFF;">Qwen/Qwen3.5-4B</b></td></tr>
139
+ <tr style="border-bottom: 1px solid #333;"><td style="padding: 10px; font-weight: bold;">Model</td><td style="padding: 10px;"><b style="color: #FFFFFF;">VisionGuardrail-4B</b></td></tr>
140
+ <tr style="border-bottom: 1px solid #333;"><td style="padding: 10px; font-weight: bold;">Model Type</td><td style="padding: 10px;"><b style="color: #FFFFFF;">Multimodal Content-Safety Classifier</b></td></tr>
141
+ <tr style="border-bottom: 1px solid #333;"><td style="padding: 10px; font-weight: bold;">Training Dataset</td><td style="padding: 10px;"><b style="color: #FFFFFF;">prithivMLmods/ImageShield-Guardrail-Pro</b></td></tr>
142
+ <tr style="border-bottom: 1px solid #333;"><td style="padding: 10px; font-weight: bold;">Training Objective</td><td style="padding: 10px;"><b style="color: #FFFFFF;">Content-safety guardrail classification</b></td></tr>
143
+ <tr style="border-bottom: 1px solid #333;"><td style="padding: 10px; font-weight: bold;">Primary Classification</td><td style="padding: 10px;"><b style="color: #FFFFFF;">Safe / Unsafe</b></td></tr>
144
+ <tr style="border-bottom: 1px solid #333;"><td style="padding: 10px; font-weight: bold;">Safety Focus</td><td style="padding: 10px;"><b style="color: #FFFFFF;">Not Safe for Work (NSFW) Sensual Content</b></td></tr>
145
+ <tr style="border-bottom: 1px solid #333;"><td style="padding: 10px; font-weight: bold;">Visual Analysis</td><td style="padding: 10px;"><b style="color: #FFFFFF;">Dress Codes, Poses, Exposure & Settings</b></td></tr>
146
+ <tr><td style="padding: 10px; font-weight: bold;">Training Framework</td><td style="padding: 10px;"><b style="color: #FFFFFF;">TRL</b></td></tr>
147
+ </tbody>
148
+ </table>
149
+
150
+ <h2 style="color: #FFFFFF; font-weight: 700; font-size: 22px; margin-top: 30px; border-bottom: 1px solid #333; padding-bottom: 5px;">Intended Use</h2>
151
+ <ul style="list-style-type: none; padding-left: 0; color: #FFFFFF; font-size: 15px;">
152
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Content Safety Classification</b>: Classifying visual media as safe or unsafe.</li>
153
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">NSFW Sensual Content Detection</b>: Supporting research into automated detection of potentially sensitive and sexually suggestive visual content.</li>
154
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Parental Controls</b>: Building conservative visual content-safety filtering systems.</li>
155
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Content Moderation</b>: Supporting automated safety classification pipelines.</li>
156
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Multimodal Safety Research</b>: Evaluating content-safety behavior in multimodal language models.</li>
157
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Guardrail Development</b>: Researching structured safety classification and filtering workflows.</li>
158
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Visual Safety Analysis</b>: Analyzing clothing, dress codes, poses, framing, and visual settings for content-safety signals.</li>
159
+ </ul>
160
+
161
+ <h2 style="color: #FFFFFF; font-weight: 700; font-size: 22px; margin-top: 30px; border-bottom: 1px solid #333; padding-bottom: 5px;">Limitations</h2>
162
+ <ul style="list-style-type: none; padding-left: 0; color: #FFFFFF; font-size: 15px;">
163
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Experimental Model</b>: The model may produce incorrect or inconsistent classifications.</li>
164
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">False Positives</b>: Benign content may occasionally be classified as unsafe due to the conservative classification threshold.</li>
165
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">False Negatives</b>: Unsafe content may occasionally be missed.</li>
166
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Context Sensitivity</b>: Classification performance depends on image quality, visual context, and the provided instruction.</li>
167
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Conservative Policy</b>: The model intentionally uses a strict classification threshold and may flag content that would not be considered NSFW under less restrictive moderation policies.</li>
168
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Visual Ambiguity</b>: Clothing, poses, artistic styles, and contextual cues may sometimes be difficult to interpret accurately.</li>
169
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">Automated Classification</b>: The model should not be treated as a definitive legal or safety determination.</li>
170
+ </ul>
171
+
172
+ <h2 style="color: #FFFFFF; font-weight: 700; font-size: 22px; margin-top: 30px; border-bottom: 1px solid #333; padding-bottom: 5px;">Acknowledgements</h2>
173
+ <ul style="list-style-type: none; padding-left: 0; color: #FFFFFF; font-size: 15px;">
174
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <a href="https://huggingface.co/Qwen/Qwen3.5-4B" style="color: #FF4500; text-decoration: none;">Qwen/Qwen3.5-4B</a>: Base multimodal model used for this project.</li>
175
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <a href="https://huggingface.co/datasets/prithivMLmods/ImageShield-Guardrail-Pro" style="color: #FF4500; text-decoration: none;">ImageShield-Guardrail-Pro</a>: Content-safety guardrail dataset used for training VisionGuardrail-4B.</li>
176
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <b style="color: #FFFFFF;">TRL</b> – <a href="https://huggingface.co/docs/trl/en/index" style="color: #FF4500; text-decoration: none;">Transformers Reinforcement Learning</a>: 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.</li>
177
+ <li style="padding-left: 25px; position: relative; margin-bottom: 10px;"><span style="position: absolute; left: 0; color: #FF4500; font-weight: bold;">+</span> <a href="https://huggingface.co/docs/transformers/en/index" style="color: #FF4500; text-decoration: none;">Transformers</a>: Transformers provides state-of-the-art machine learning models for text, computer vision, audio, video, and multimodal tasks, supporting both inference and training.</li>
178
+ </ul>
179
+ </div>
180
+
181
+ <script>
182
+ function copyCode(btn) {
183
+ const code = btn.parentElement.querySelector('code').innerText;
184
+ navigator.clipboard.writeText(code).then(() => {
185
+ btn.innerText = 'Copied!';
186
+ setTimeout(() => { btn.innerText = 'Copy'; }, 2000);
187
+ });
188
+ }
189
+ </script>