模型库 / TostAI/nsfw-image-detection-large

nsfw-image-detection-large

TostAI en
TostAI/nsfw-image-detection-large
3,417,792
下载量
18
收藏数
7
浏览量
cc-by-nc-sa-4.0
许可

简介

🚀 FocalNet NSFW图像分类器:您的内容审核超级英雄!🦸‍♂️

模型卡片

许可协议 cc-by-nc-sa-4.0
语言
en

模型配置

模型类型 focalnet
架构 FocalNetForImageClassification

模型详情

已翻译

🚀 FocalNet NSFW 图像分类器:您的内容审核超级英雄!🦸‍♂️

🌟 发现智能审核的力量!

👋 准备好迎接内容审核的革命了吗?认识一下 FocalNet NSFW 图像分类器——您在对抗不当内容战役中全新的、闪电般快速且超级智能的助手!

🎭 我是谁?

我是一个基于强大的 microsoft/focalnet-base 构建的先进 AI 模型。我的超能力是将图像闪电般快速分类为三个类别:

  • 🟢 SAFE(安全):"绿灯!这个内容没问题!"
  • 🟡 QUESTIONABLE(可疑):"嗯……也许我们应该再看一眼?"
  • 🔴 UNSAFE(不安全):"哇!在有人看到之前赶紧阻止!"

🦾 我能做什么?

想象一下,您是互联网星系的守护者。您的使命?保护用户免受令人震惊的不当内容侵害。但如何每天审核数百万张图像?这就是我登场的时候了!

  • 🕵️‍♂️ 闪电检测: 我会比您说"安全内容"更快地分析每一个像素!
  • 🛡️ 保护屏障: 我会守护您的平台,屏蔽用户不希望看到的内容。
  • 🎯 狙击精度: 我的眼睛如此锐利,能以手术般的精准度发现潜在威胁。

🚀 如何使用我?

准备好冒险了吗?以下是如何运用我的力量:

  1. 安装我的能力:
    pip install transformers==4.37.2 torch==2.3.1 torchvision Pillow

  2. 在代码中召唤我:
    ```python
    import os
    from PIL import Image
    import torch
    from torchvision import transforms
    from transformers import AutoProcessor, FocalNetForImageClassification

# Path to the folder with images
image_folder = ""
# Path to the model
model_path = "MichalMlodawski/nsfw-image-detection-large"

# List of jpg files in the folder
jpg_files = [file for file in os.listdir(image_folder) if file.lower().endswith(".jpg")]

# Check if there are jpg files in the folder
if not jpg_files:
print("🚫 No jpg files found in folder:", image_folder)
exit()

# Load the model and feature extractor
feature_extractor = AutoProcessor.from_pretrained(model_path)
model = FocalNetForImageClassification.from_pretrained(model_path)
model.eval()

# Image transformations
transform = transforms.Compose([
transforms.Resize((512, 512)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])

# Mapping from model labels to NSFW categories
label_to_category = {
"LABEL_0": "Safe",
"LABEL_1": "Questionable",
"LABEL_2": "Unsafe"
}

# Processing and prediction for each image
results = []
for jpg_file in jpg_files:
selected_image = os.path.join(image_folder, jpg_file)
image = Image.open(selected_image).convert("RGB")
image_tensor = transform(image).unsqueeze(0)

   # Process image using feature_extractor
   inputs = feature_extractor(images=image, return_tensors="pt")

   # Prediction using the model
   with torch.no_grad():
       outputs = model(**inputs)
       probabilities = torch.nn.functional.softmax(outputs.logits, dim=-1)
       confidence, predicted = torch.max(probabilities, 1)

   # Get the label from the model's configuration
   label = model.config.id2label[predicted.item()]

   results.append((jpg_file, label, confidence.item() * 100))

# Display results
print("🖼️ NSFW Classification Results 🖼️")
print("=" * 40)
for jpg_file, label, confidence in results:
category = label_to_category.get(label, "Unknown")
emoji = {"Safe": "✅", "Questionable": "⚠️", "Unsafe": "🔞"}.get(category, "❓")
confidence_bar = "🟩" * int(confidence // 10) + "⬜" * (10 - int(confidence // 10))

   print(f"📄 File name: {jpg_file}")
   print(f"🏷️ Model Label: {label}")
   print(f"{emoji} NSFW Category: {category}")
   print(f"🎯 Confidence: {confidence:.2f}% {confidence_bar}")
   print(f"{'=' * 40}")

print("🏁 Classification completed! 🎉")
```

🎉 我的独特之处?

  • 🚄 光速处理: 在您喝完早晨咖啡之前,我就能分析数千张图像!
  • 🧠 智商100: 我从数百万个示例中学习,所以我知道所有套路!
  • 🛠️ 易于集成: 我会比猫跳上键盘还快地融入您的代码!
  • 🌐 多语言支持: 我理解来自所有文化和背景的图像!
  • 🔄 持续学习: 我不断改进,适应新趋势和挑战!

🔬 技术规格

  • 基础模型: microsoft/focalnet-base
  • 模型类型: FocalNetForImageClassification
  • 输入尺寸: 512x512 像素
  • 输出: 3 个类别(安全、可疑、不安全)
  • 框架: PyTorch
  • 语言: Python 3.6+

🚀 使用场景

  1. 社交媒体平台: 保持用户生成内容的清洁和安全。
  2. 电商网站: 确保产品图像符合社区标准。
  3. 约会应用: 为所有用户维护一个尊重的环境。
  4. 内容分享平台: 自动过滤可能不当的上传内容。
  5. 教育平台: 确保学习材料适合相应年龄段。

🏋️ 训练与性能

  • 训练数据: 数百万张涵盖各类别的多样化图像
  • 微调: 针对精确分类的专业 NSFW 数据集
  • 准确率: 在基准 NSFW 检测任务上达到 95%+
  • 延迟: 在标准 GPU 硬件上每张图像 <100ms

⚠️ 重要警告(因为每个超级英雄都有弱点)

  1. 🎢 不适用于极端挑战: 我很棒,但不要将我用于错误代价超过烤焦面包的场合!
  2. 🤖 我不是天网: 我有时会犯错,所以别让我独自守着红色按钮!
  3. 🕵️‍♂️ 尊重隐私: 确保您有权处理给我看的图像。我不喜欢窥探的眼睛!
  4. 🔄 我需要更新: 世界在变,我也必须变!定期检查我是否需要刷新。
  5. 🤝 协作是关键: 我是出色的助手,但最终决定还是留给人类。我们联手,无人能敌!

🌈 未来是光明的!

请记住,我是一个持续研究过程的一部分。每次更新,我都会变得更聪明、更快、更令人惊叹!

准备好一起革新内容审核了吗?将我带进您的项目,见证奇迹的发生!🎩✨

今天就加入 AI 革命,让互联网变得更安全!🌍💪

📚 参考资料与资源

让我们一次一张图像,让数字世界更安全!🌟

标签

focalnet en license:cc-by-nc-sa-4.0 region:us

操作


详细信息

厂商
TostAI
模型类型
focalnet
许可(HF)
cc-by-nc-sa-4.0
语言
en