Spaces:
Sleeping
Sleeping
File size: 1,127 Bytes
373e186 49babfe 93a4013 49babfe 373e186 49babfe 40ee638 3f9b377 a64f4ed 40ee638 49babfe f83a3a3 40ee638 49babfe 4744348 40ee638 5dde09c 40ee638 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import gradio as gr
from PIL import Image
from vit_model_test import CustomModel
# Initialize the model
model = CustomModel()
def predict(image: Image.Image):
# ืืื ืืชืืฆืข ืขืืืื ืืชืืื ื
label, confidence = model.predict(image)
result = "AI image" if label == 1 else "Real image"
return result, f"Confidence: {confidence:.2f}%"
# ืืฆืืจืช ืืืฉืง Gradio ืขื ืืืืื ืฉืืืฆื ืืืื ืืืฉืื ืืืืื
demo = gr.Interface(
fn=predict,
inputs=gr.Image(type="pil"),
outputs=[gr.Textbox(), gr.Textbox()],
title="Vision Transformer Model",
description="Upload an image to classify it as AI-generated or Real.",
live=True, # ืืืคืฉืจ ืืืฆืื ืกืืืืก ืืืื ืืืช
theme="compact", # ืืคืฉืจื ืืืืกืืฃ ืขืืฆืื ืืงืฆืืขื
css=".loading-message { display: none; }"
)
# ืืืืจืช ืืกืจืืื ืฉืืืคืืข ืืืื ืืืฉืื
demo.loading = "https://cdn-uploads.huggingface.co/production/uploads/66d6f1b3b50e35e1709bfdf7/x7Ud8PO9QPfmrTvBVcCKE.mp4" # ืืืกืฃ ืืช ืฉื ืงืืืฅ ืืืืืืื
# ืืฉืงืช ืืืืฉืง
demo.launch()
|