🚀 siglip2-x256-explicit-content
siglip2-x256-explicit-content 是一個基於視覺語言編碼器的模型,它在 siglip2-base-patch16-256 的基礎上進行微調,用於 多類別圖像分類。該模型基於 SiglipForImageClassification 架構構建,經過訓練能夠識別和分類圖像中的內容類型,尤其適用於 色情、暗示性或安全媒體的過濾。
🚀 快速開始
安裝依賴
pip install -q transformers torch pillow gradio
推理代碼
import gradio as gr
from transformers import AutoImageProcessor, SiglipForImageClassification
from PIL import Image
import torch
model_name = "prithivMLmods/siglip2-x256-explicit-content"
model = SiglipForImageClassification.from_pretrained(model_name)
processor = AutoImageProcessor.from_pretrained(model_name)
id2label = {
"0": "Anime Picture",
"1": "Hentai",
"2": "Normal",
"3": "Pornography",
"4": "Enticing or Sensual"
}
def classify_explicit_content(image):
image = Image.fromarray(image).convert("RGB")
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
prediction = {
id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
}
return prediction
iface = gr.Interface(
fn=classify_explicit_content,
inputs=gr.Image(type="numpy"),
outputs=gr.Label(num_top_classes=5, label="Predicted Content Type"),
title="siglip2-x256-explicit-content",
description="Classifies images into explicit, suggestive, or safe categories (e.g., Hentai, Pornography, Normal)."
)
if __name__ == "__main__":
iface.launch()
✨ 主要特性
- 多類別圖像分類:能夠將圖像分為多個類別,包括動漫圖片、色情內容、正常內容等。
- 內容過濾:可用於檢測和過濾色情、暗示性或安全媒體內容。
📚 詳細文檔
標籤空間:5 個類別
該模型將每張圖像分類到以下內容類別之一:
Class 0: "Anime Picture"
Class 1: "Hentai"
Class 2: "Normal"
Class 3: "Pornography"
Class 4: "Enticing or Sensual"
分類報告
Classification Report:
precision recall f1-score support
Anime Picture 0.8940 0.8718 0.8827 5600
Hentai 0.8961 0.8935 0.8948 4180
Normal 0.9100 0.8895 0.8997 5503
Pornography 0.9496 0.9654 0.9574 5600
Enticing or Sensual 0.9132 0.9429 0.9278 5600
accuracy 0.9137 26483
macro avg 0.9126 0.9126 0.9125 26483
weighted avg 0.9135 0.9137 0.9135 26483
預期用途
此模型適用於以下應用場景:
- 內容審核:自動檢測不適合工作場所(NSFW)或具有暗示性的內容。
- 家長控制:實現基於人工智能的過濾,確保安全的媒體瀏覽。
- 數據集預處理:清理和分類圖像數據集,用於研究或部署。
- 在線平臺:幫助執行上傳內容和用戶生成媒體的內容準則。
📄 許可證
本項目採用 Apache-2.0 許可證。
引用
SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features https://arxiv.org/pdf/2502.14786
模型相關信息
屬性 |
詳情 |
基礎模型 |
google/siglip2-base-patch16-256 |
任務類型 |
圖像分類 |
庫名稱 |
transformers |
標籤 |
siglip2、256、patch16、成人內容檢測、明確內容檢測 |
模型圖片
