Spaces:
Runtime error
Runtime error
import gradio as gr | |
def classify_image(image): | |
# Preprocess the image | |
inputs = processor(images=image, return_tensors="pt") | |
# Predict | |
outputs = model(**inputs) | |
predictions = outputs.logits.softmax(dim=-1) | |
# Assuming your model returns two probabilities: [real, AI-generated] | |
probs = predictions.detach().numpy()[0] | |
labels = ['Real', 'AI-generated'] | |
result = {labels[i]: probs[i] for i in range(len(labels))} | |
return result | |
# Create the Gradio interface | |
iface = gr.Interface(fn=classify_image, inputs=gr.inputs.Image(shape=(224, 224)), outputs=gr.outputs.Label(num_top_classes=2)) | |
iface.launch() |