Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -15,6 +15,30 @@ models=[
|
|
15 |
"umm-maybe/AI-image-detector",
|
16 |
]
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
def aiornot0(image):
|
19 |
labels = ["Real", "AI"]
|
20 |
mod=models[0]
|
@@ -87,14 +111,19 @@ with gr.Blocks() as app:
|
|
87 |
with gr.Box():
|
88 |
lab0 = gr.HTML(f"""Testing on Model: {models[0]}""")
|
89 |
outp0 = gr.HTML("""""")
|
|
|
90 |
with gr.Box():
|
91 |
lab1 = gr.HTML(f"""Testing on Model: {models[1]}""")
|
92 |
outp1 = gr.HTML("""""")
|
|
|
93 |
with gr.Box():
|
94 |
lab2 = gr.HTML(f"""Testing on Model: {models[2]}""")
|
95 |
outp2 = gr.HTML("""""")
|
|
|
96 |
btn.click(aiornot0,[inp],outp0)
|
97 |
btn.click(aiornot1,[inp],outp1)
|
98 |
btn.click(aiornot2,[inp],outp2)
|
99 |
-
|
|
|
|
|
100 |
app.launch()
|
|
|
15 |
"umm-maybe/AI-image-detector",
|
16 |
]
|
17 |
|
18 |
+
pipe0 = pipeline("image-classification", f"{models[0]}")
|
19 |
+
pipe1 = pipeline("image-classification", f"{models[1]}")
|
20 |
+
pipe2 = pipeline("image-classification", f"{models[2]}")
|
21 |
+
|
22 |
+
def image_classifier0(image):
|
23 |
+
outputs = pipe0(image)
|
24 |
+
results = {}
|
25 |
+
for result in outputs:
|
26 |
+
results[result['label']] = result['score']
|
27 |
+
return results
|
28 |
+
def image_classifier1(image):
|
29 |
+
outputs = pipe1(image)
|
30 |
+
results = {}
|
31 |
+
for result in outputs:
|
32 |
+
results[result['label']] = result['score']
|
33 |
+
return results
|
34 |
+
def image_classifier2(image):
|
35 |
+
outputs = pipe2(image)
|
36 |
+
results = {}
|
37 |
+
for result in outputs:
|
38 |
+
results[result['label']] = result['score']
|
39 |
+
return results
|
40 |
+
|
41 |
+
|
42 |
def aiornot0(image):
|
43 |
labels = ["Real", "AI"]
|
44 |
mod=models[0]
|
|
|
111 |
with gr.Box():
|
112 |
lab0 = gr.HTML(f"""Testing on Model: {models[0]}""")
|
113 |
outp0 = gr.HTML("""""")
|
114 |
+
n_out0=gr.Label()
|
115 |
with gr.Box():
|
116 |
lab1 = gr.HTML(f"""Testing on Model: {models[1]}""")
|
117 |
outp1 = gr.HTML("""""")
|
118 |
+
n_out1=gr.Label()
|
119 |
with gr.Box():
|
120 |
lab2 = gr.HTML(f"""Testing on Model: {models[2]}""")
|
121 |
outp2 = gr.HTML("""""")
|
122 |
+
n_out2=gr.Label()
|
123 |
btn.click(aiornot0,[inp],outp0)
|
124 |
btn.click(aiornot1,[inp],outp1)
|
125 |
btn.click(aiornot2,[inp],outp2)
|
126 |
+
btn.click(image_classifier0,[inp],n_out0)
|
127 |
+
btn.click(image_classifier1,[inp],n_out1)
|
128 |
+
btn.click(image_classifier2,[inp],n_out2)
|
129 |
app.launch()
|