Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,8 @@ import gradio as gr
|
|
2 |
import torch
|
3 |
from transformers import AutoFeatureExtractor, AutoModelForImageClassification, pipeline
|
4 |
from numpy import exp
|
5 |
-
|
|
|
6 |
def softmax(vector):
|
7 |
e = exp(vector)
|
8 |
return e / e.sum()
|
@@ -27,10 +28,12 @@ def aiornot0(image):
|
|
27 |
print (logits)
|
28 |
probability = softmax(logits)
|
29 |
print(f'PROBABILITY ::: {probability}')
|
30 |
-
|
|
|
|
|
31 |
prediction = logits.argmax(-1).item()
|
32 |
label = labels[prediction]
|
33 |
-
return
|
34 |
def aiornot1(image):
|
35 |
labels = ["Real", "AI"]
|
36 |
mod=models[1]
|
@@ -67,7 +70,8 @@ with gr.Blocks() as app:
|
|
67 |
btn = gr.Button()
|
68 |
|
69 |
with gr.Column():
|
70 |
-
outp0 = gr.Textbox(label=f'{models[0]}')
|
|
|
71 |
outp1 = gr.Textbox(label=f'{models[1]}')
|
72 |
outp2 = gr.Textbox(label=f'{models[2]}')
|
73 |
btn.click(aiornot0,[inp],outp0)
|
|
|
2 |
import torch
|
3 |
from transformers import AutoFeatureExtractor, AutoModelForImageClassification, pipeline
|
4 |
from numpy import exp
|
5 |
+
import pandas as pd
|
6 |
+
|
7 |
def softmax(vector):
|
8 |
e = exp(vector)
|
9 |
return e / e.sum()
|
|
|
28 |
print (logits)
|
29 |
probability = softmax(logits)
|
30 |
print(f'PROBABILITY ::: {probability}')
|
31 |
+
print(probability[0])
|
32 |
+
px = pd.DataFrame(probability.numpy())
|
33 |
+
|
34 |
prediction = logits.argmax(-1).item()
|
35 |
label = labels[prediction]
|
36 |
+
return px
|
37 |
def aiornot1(image):
|
38 |
labels = ["Real", "AI"]
|
39 |
mod=models[1]
|
|
|
70 |
btn = gr.Button()
|
71 |
|
72 |
with gr.Column():
|
73 |
+
#outp0 = gr.Textbox(label=f'{models[0]}')
|
74 |
+
outp0 = gr.BarPlot(label=f'{models[0]}', vertical=False)
|
75 |
outp1 = gr.Textbox(label=f'{models[1]}')
|
76 |
outp2 = gr.Textbox(label=f'{models[2]}')
|
77 |
btn.click(aiornot0,[inp],outp0)
|