TLeonidas commited on
Commit
f29ba06
1 Parent(s): 5f8a9c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -3
app.py CHANGED
@@ -1,7 +1,21 @@
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello, " + name + ". Thank you for yout visit! \n This Project will be available after the Gulf Coast Conference & Expo on AI. \n You are welcome to join us at this event. \n Find out more at https://hcc.idloom.events/artificial-intelligence-conference-dit/"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
  iface.launch()
 
1
  import gradio as gr
2
 
3
+ def classify_image(image):
4
+ # Preprocess the image
5
+ inputs = processor(images=image, return_tensors="pt")
6
+
7
+ # Predict
8
+ outputs = model(**inputs)
9
+ predictions = outputs.logits.softmax(dim=-1)
10
+
11
+ # Assuming your model returns two probabilities: [real, AI-generated]
12
+ probs = predictions.detach().numpy()[0]
13
+ labels = ['Real', 'AI-generated']
14
+ result = {labels[i]: probs[i] for i in range(len(labels))}
15
+
16
+ return result
17
+
18
+ # Create the Gradio interface
19
+ iface = gr.Interface(fn=classify_image, inputs=gr.inputs.Image(shape=(224, 224)), outputs=gr.outputs.Label(num_top_classes=2))
20
 
 
21
  iface.launch()