Spaces:
Runtime error
Runtime error
File size: 639 Bytes
c695964 f29ba06 c695964 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
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() |