Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,7 @@ pipe2 = pipeline("image-classification", f"{models[2]}")
|
|
23 |
|
24 |
fin_sum=[]
|
25 |
def image_classifier0(image):
|
26 |
-
labels = ["
|
27 |
outputs = pipe0(image)
|
28 |
results = {}
|
29 |
result_test={}
|
@@ -36,7 +36,7 @@ def image_classifier0(image):
|
|
36 |
fin_sum.append(results)
|
37 |
return results
|
38 |
def image_classifier1(image):
|
39 |
-
labels = ["
|
40 |
outputs = pipe1(image)
|
41 |
results = {}
|
42 |
result_test={}
|
@@ -49,7 +49,7 @@ def image_classifier1(image):
|
|
49 |
fin_sum.append(results)
|
50 |
return results
|
51 |
def image_classifier2(image):
|
52 |
-
labels = ["
|
53 |
outputs = pipe2(image)
|
54 |
results = {}
|
55 |
result_test={}
|
@@ -119,7 +119,7 @@ def aiornot1(image):
|
|
119 |
fin_sum.append(results)
|
120 |
return gr.HTML.update(html_out),results
|
121 |
def aiornot2(image):
|
122 |
-
labels = ["
|
123 |
mod=models[2]
|
124 |
feature_extractor2 = AutoFeatureExtractor.from_pretrained("microsoft/resnet-50")
|
125 |
model2 = AutoModelForImageClassification.from_pretrained(mod)
|
@@ -160,8 +160,8 @@ def load_url(url):
|
|
160 |
|
161 |
def tot_prob():
|
162 |
try:
|
163 |
-
fin_out = fin_sum[0]["Real"]+fin_sum[1]["Real"]+fin_sum[2]["Real"]
|
164 |
-
fin_out = fin_out/
|
165 |
fin_sub = 1-fin_out
|
166 |
out={
|
167 |
"Real":f"{fin_out}",
|
@@ -228,7 +228,7 @@ with gr.Blocks() as app:
|
|
228 |
return(f"{uid}tmp_src.png")
|
229 |
inp.change(upd,inp,inp,show_progress=False)
|
230 |
|
231 |
-
btn.click(fin_clear,None,fin)
|
232 |
load_btn.click(load_url,in_url,[inp,mes])
|
233 |
|
234 |
btn.click(aiornot0,[inp],[outp0,n_out0]).then(tot_prob,None,fin,show_progress=False)
|
|
|
23 |
|
24 |
fin_sum=[]
|
25 |
def image_classifier0(image):
|
26 |
+
labels = ["AI","Real"]
|
27 |
outputs = pipe0(image)
|
28 |
results = {}
|
29 |
result_test={}
|
|
|
36 |
fin_sum.append(results)
|
37 |
return results
|
38 |
def image_classifier1(image):
|
39 |
+
labels = ["AI","Real"]
|
40 |
outputs = pipe1(image)
|
41 |
results = {}
|
42 |
result_test={}
|
|
|
49 |
fin_sum.append(results)
|
50 |
return results
|
51 |
def image_classifier2(image):
|
52 |
+
labels = ["AI","Real"]
|
53 |
outputs = pipe2(image)
|
54 |
results = {}
|
55 |
result_test={}
|
|
|
119 |
fin_sum.append(results)
|
120 |
return gr.HTML.update(html_out),results
|
121 |
def aiornot2(image):
|
122 |
+
labels = ["Real", "AI"]
|
123 |
mod=models[2]
|
124 |
feature_extractor2 = AutoFeatureExtractor.from_pretrained("microsoft/resnet-50")
|
125 |
model2 = AutoModelForImageClassification.from_pretrained(mod)
|
|
|
160 |
|
161 |
def tot_prob():
|
162 |
try:
|
163 |
+
fin_out = fin_sum[0]["Real"]+fin_sum[1]["Real"]+fin_sum[2]["Real"]+fin_sum[3]["Real"]+fin_sum[4]["Real"]+fin_sum[5]["Real"]
|
164 |
+
fin_out = fin_out/6
|
165 |
fin_sub = 1-fin_out
|
166 |
out={
|
167 |
"Real":f"{fin_out}",
|
|
|
228 |
return(f"{uid}tmp_src.png")
|
229 |
inp.change(upd,inp,inp,show_progress=False)
|
230 |
|
231 |
+
btn.click(fin_clear,None,fin,show_progress=False)
|
232 |
load_btn.click(load_url,in_url,[inp,mes])
|
233 |
|
234 |
btn.click(aiornot0,[inp],[outp0,n_out0]).then(tot_prob,None,fin,show_progress=False)
|