Spaces:
Running
Running
import gradio as gr | |
from transformers import pipeline | |
# 建立 image-classification pipeline,使用 FaceAIorNot 模型 | |
pipe = pipeline( | |
task="image-classification", | |
model="hchcsuim/FaceAIorNot" | |
) | |
# 預測函數:回傳圖片和分類結果 | |
def predict(input_img): | |
predictions = pipe(input_img) | |
return input_img, {p["label"]: p["score"] for p in predictions} | |
# 精簡中英文對照版說明 | |
model_card = """ | |
--- | |
## 🧠 Model Description / 模型簡介 | |
This model classifies face images into two categories: **AI-generated** and **Not AI-generated**. | |
本模型將臉部圖片分類為「AI生成」或「非AI生成」。 | |
🔗 Model Homepage / 模型主頁:https://huggingface.co/hchcsuim/FaceAIorNot | |
--- | |
### 📊 Evaluation Results / 模型評估 | |
- Accuracy 準確率: **99.35%** | |
- Precision 精確率: **99.25%** | |
- Recall 召回率: **99.47%** | |
- F1-score F1 分數: **99.36%** | |
- Loss 損失: **0.0233** | |
Dataset: 105,330 face images (50% real / 50% AI), from 17 datasets, 14 generation techniques, 90% train / 10% test | |
資料集共 105,330 張臉部圖片(50% 真人 / 50% AI),來自 17 個資料集、14 種生成技術,90% 訓練 / 10% 測試 | |
--- | |
### ⚠️ Disclaimer / 免責聲明 | |
This model is for research and educational use only. Not 100% accurate. | |
請僅用於研究與教育用途,結果非百分之百準確。 | |
Do not use for identity verification, legal judgment, or public exposure. | |
請勿用於身分驗證、法律判斷或公開揭露等用途。 | |
--- | |
### 👨💻 About the Developer / 關於開發者 | |
**Hung Chih Hsiang(洪誌翔)** | |
Master’s student in Information Management, Cheng Shiu University. | |
正修科技大學 資訊管理所碩士生。 | |
Focus: deepfake detection, snake recognition, system development, DevOps | |
專長:深度偽造辨識、蛇類辨識、系統開發與運維 | |
--- | |
### 🤝 Open to Collaborations / 歡迎合作 | |
I'm open to: | |
我歡迎以下方向的合作: | |
- Research or commercial AI projects / AI 研究或商業應用 | |
- Model training, optimization, deployment / 模型訓練、優化與部署 | |
- System development, MLOps & DevOps / 系統開發與 MLOps、DevOps 整合 | |
--- | |
📧 Email: hchcsuim@gmail.com | |
🐙 GitHub: https://github.com/hchcsuim | |
""" | |
# Gradio 介面設定(雙語版) | |
gradio_app = gr.Interface( | |
fn=predict, | |
inputs=gr.Image(label="📸 Select / Upload Face Photo 選擇或上傳臉部照片", sources=["upload", "webcam"], type="pil"), | |
outputs=[ | |
gr.Image(label="🖼️ Input Image / 輸入圖片"), | |
gr.Label(label="🔍 Classification Result / 判斷結果", num_top_classes=2) | |
], | |
title="FaceAIorNot | 真人臉,還是 AI 生成人臉?", | |
description=( | |
"🤖 Upload or take a face photo to see if it's AI-generated or real.\n" | |
"🧑 上傳或拍攝一張臉部照片,判斷是真人還是 AI 生成圖。" | |
), | |
article=model_card, | |
allow_flagging="never" | |
) | |
if __name__ == "__main__": | |
gradio_app.launch() | |