🚀 AI画像検出器
このモデルは、画像が実写かAI生成かを検出するために設計されています。Vision Transformer (ViT)アーキテクチャを使用して、正確な分類を提供します。
🚀 クイックスタート
このモデルを使用することで、画像が実写かAI生成かを検出できます。以下に使用方法を説明します。
✨ 主な機能
- 画像が実写かAI生成かを高精度に検出します。
- Vision Transformer (ViT)アーキテクチャを利用して、正確な分類を提供します。
💻 使用例
基本的な使用法
from transformers import ViTImageProcessor, ViTForImageClassification
from PIL import Image
import torch
processor = ViTImageProcessor.from_pretrained("C:/Users/SUPREME TECH/Desktop/SAM3/ai-image-detector")
model = ViTForImageClassification.from_pretrained("C:/Users/SUPREME TECH/Desktop/SAM3/ai-image-detector")
def detect_image(image_path):
image = Image.open(image_path)
if image.mode != 'RGB':
image = image.convert('RGB')
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
predictions = outputs.logits.softmax(dim=-1)
scores = predictions[0].tolist()
results = [
{"label": "REAL", "score": scores[0]},
{"label": "FAKE", "score": scores[1]}
]
results.sort(key=lambda x: x["score"], reverse=True)
return {
"prediction": results[0]["label"],
"confidence": f"{results[0]['score']*100:.2f}%",
"detailed_scores": [
f"{r['label']}: {r['score']*100:.2f}%"
for r in results
]
}
if __name__ == "__main__":
image_path = "path/to/your/image.jpg"
try:
result = detect_image(image_path)
print("\n画像解析結果:")
print(f"分類: {result['prediction']}")
print(f"信頼度: {result['confidence']}")
print("\n詳細:")
for score in result['detailed_scores']:
print(f"- {score}")
except Exception as e:
print(f"エラーが発生しました: {str(e)}")
高度な使用法
async function detectImage(imageFile) {
const formData = new FormData();
formData.append('image', imageFile);
const response = await fetch('YOUR_API_ENDPOINT', {
method: 'POST',
body: formData
});
return await response.json();
}
📚 ドキュメント
このモデルは画像を以下の2つのカテゴリに分類します。
- 実写画像 (0): 画像は実写で、AI生成ではありません。
- AI生成画像 (1): 画像はAIによって生成されています。
🔧 技術詳細
属性 |
詳情 |
モデルタイプ |
Vision Transformer (ViT) |
入力 |
画像 (RGB) |
出力 |
信頼度スコア付きの二値分類 |
最大画像サイズ |
224x224 (自動リサイズ) |
📦 インストール
このモデルを使用するには、以下のライブラリが必要です。
transformers>=4.30.0
torch>=2.0.0
Pillow>=9.0.0
📄 ライセンス
このモデルはMITライセンスの下で公開されています。
開発者情報