Reality / app.py
Syeda-Sana-Bibi786's picture
Update app.py
c079b6e verified
raw
history blame contribute delete
724 Bytes
import gradio as gr
from transformers import pipeline
model = pipeline("image-classification", model="Ateeqq/ai-vs-human-image-detector")
def check_image(image):
results = model(image)
label = results[0]["label"]
confidence = round(results[0]["score"] * 100, 2)
return {"prediction": label, "confidence": confidence}
with gr.Blocks() as demo:
gr.Markdown("# Reality - AI Image Detector")
image_input = gr.Image(type="pil", label="Upload Image")
output_json = gr.JSON(label="Result")
btn = gr.Button("Check Image")
btn.click(fn=check_image, inputs=image_input, outputs=output_json, api_name="predict")
demo.launch(server_name="0.0.0.0", server_port=7860, share=True , show_api=True)