VIT_Demo / app.py
litav's picture
Update app.py
6917b4f verified
raw
history blame
900 Bytes
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}%"
def video_identity(video):
return video
demo = gr.Interface(video_identity,
gr.Video(),
"https://cdn-uploads.huggingface.co/production/uploads/66d6f1b3b50e35e1709bfdf7/x7Ud8PO9QPfmrTvBVcCKE.mp4",
)
# Define the Gradio interface
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 using the Vision Transformer model."
)
# Launch the Gradio interface
demo.launch()