🚀 NSFW画像検出 – トップパフォーマー
このモデルは、NSFW画像分類用にファインチューニングされています。コンテンツを3つの重要な安全カテゴリに分類するため、モデレーション、安全フィルタリング、およびコンプライアンス対応のコンテンツ処理システムに役立ちます。
https://exnrt.com/blog/ai/fine-tuning-siglip2/
🚀 クイックスタート
このモデルを使用することで、NSFW画像を分類することができます。以下のセクションでは、具体的な使用方法を説明します。
💻 使用例
基本的な使用法
import torch
from transformers import AutoImageProcessor, SiglipForImageClassification
from PIL import Image
import torch.nn.functional as F
model_path = "Ateeqq/nsfw-image-detection"
processor = AutoImageProcessor.from_pretrained(model_path)
model = SiglipForImageClassification.from_pretrained(model_path)
image_path = r"/content/download.jpg"
image = Image.open(image_path).convert("RGB")
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs).logits
probabilities = F.softmax(logits, dim=1)
predicted_class_id = logits.argmax().item()
predicted_class_label = model.config.id2label[predicted_class_id]
confidence_scores = probabilities[0].tolist()
print(f"Predicted class ID: {predicted_class_id}")
print(f"Predicted class label: {predicted_class_label}\n")
for i, score in enumerate(confidence_scores):
label = model.config.id2label[i]
print(f"Confidence for '{label}': {score:.6f}")
出力
Predicted class ID: 2
Predicted class label: safe_normal
Confidence for 'gore_bloodshed_violent': 0.000002
Confidence for 'nudity_pornography': 0.000005
Confidence for 'safe_normal': 0.999993
📚 ドキュメント
モデル詳細
属性 |
详情 |
ベースモデル |
google/siglip2-base-patch16-224 |
タスク |
画像分類 (NSFW/安全検出) |
フレームワーク |
PyTorch / Hugging Face Transformers |
ファインチューニングデータセット |
3つのコンテンツカテゴリを持つカスタムデータセット |
選択されたチェックポイント |
エポック5 |
バッチサイズ |
64 |
トレーニングエポック数 |
5 |
混合行列

カテゴリ
ID |
ラベル |
除外項目 |
0 |
gore_bloodshed_violent |
戦闘、事故、怒り |
1 |
nudity_pornography |
通常のロマンス、通常のキス |
2 |
safe_normal |
|
ラベルマッピング
label2id = {'gore_bloodshed_violent': 0, 'nudity_pornography': 1, 'safe_normal': 2}
id2label = {0: 'gore_bloodshed_violent', 1: 'nudity_pornography', 2: 'safe_normal'}
トレーニングメトリクス (エポック5選択)
エポック |
トレーニング損失 |
検証損失 |
正確度 |
1 |
0.0765 |
0.1166 |
95.70% |
2 |
0.0719 |
0.0477 |
98.34% |
3 |
0.0089 |
0.0634 |
98.05% |
4 |
0.0109 |
0.0437 |
98.61% |
5 |
0.0001 |
0.0389 |
99.02% |
エポックトレーニング結果

- トレーニング実行時間: 1時間21分40秒
- 最終トレーニング損失: 0.0727
- ステップ/秒: 0.11 | サンプル/秒: 6.99
📄 ライセンス
このモデルは、Apache-2.0ライセンスの下で提供されています。