Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,8 +8,8 @@ model = CustomModel()
|
|
8 |
|
9 |
def predict(image: Image.Image):
|
10 |
# 讝诪谉 讞讬砖讜讘 诪讜讚诇 (诪讚讜诪讛)
|
11 |
-
time.sleep(
|
12 |
-
|
13 |
# 讛驻注诇转 讛诪讜讚诇 讻讚讬 诇住讜讜讙 讗转 讛转诪讜谞讛
|
14 |
label, confidence = model.predict(image)
|
15 |
result = "AI image" if label == 1 else "Real image"
|
@@ -32,15 +32,15 @@ with gr.Blocks() as demo:
|
|
32 |
image_input = gr.Image(type="pil", label="Upload an image")
|
33 |
|
34 |
# 讜讬讚讗讜 讗谞讬诪爪讬讛 (诪讜住转专 讘讛转讞诇讛)
|
35 |
-
animation = gr.Video("https://cdn-uploads.huggingface.co/production/uploads/66d6f1b3b50e35e1709bfdf7/x7Ud8PO9QPfmrTvBVcCKE.mp4", visible=
|
36 |
-
|
37 |
# 转讜爪讗讜转
|
38 |
output_label = gr.Textbox(label="Classification Result", visible=False)
|
39 |
output_confidence = gr.Textbox(label="Confidence", visible=False)
|
40 |
|
41 |
# 讗讬专讜注讬诐
|
42 |
image_input.change(loading_animation, inputs=image_input, outputs=[animation, output_label, output_confidence])
|
43 |
-
image_input.
|
44 |
|
45 |
# 讛砖拽转 讛诪诪砖拽
|
46 |
demo.launch()
|
|
|
8 |
|
9 |
def predict(image: Image.Image):
|
10 |
# 讝诪谉 讞讬砖讜讘 诪讜讚诇 (诪讚讜诪讛)
|
11 |
+
time.sleep(5) # 住讬诪讜诇爪讬讛 砖诇 讝诪谉 注讬讘讜讚
|
12 |
+
|
13 |
# 讛驻注诇转 讛诪讜讚诇 讻讚讬 诇住讜讜讙 讗转 讛转诪讜谞讛
|
14 |
label, confidence = model.predict(image)
|
15 |
result = "AI image" if label == 1 else "Real image"
|
|
|
32 |
image_input = gr.Image(type="pil", label="Upload an image")
|
33 |
|
34 |
# 讜讬讚讗讜 讗谞讬诪爪讬讛 (诪讜住转专 讘讛转讞诇讛)
|
35 |
+
animation = gr.Video("https://cdn-uploads.huggingface.co/production/uploads/66d6f1b3b50e35e1709bfdf7/x7Ud8PO9QPfmrTvBVcCKE.mp4", visible=False)
|
36 |
+
|
37 |
# 转讜爪讗讜转
|
38 |
output_label = gr.Textbox(label="Classification Result", visible=False)
|
39 |
output_confidence = gr.Textbox(label="Confidence", visible=False)
|
40 |
|
41 |
# 讗讬专讜注讬诐
|
42 |
image_input.change(loading_animation, inputs=image_input, outputs=[animation, output_label, output_confidence])
|
43 |
+
image_input.change(show_results, inputs=image_input, outputs=[animation, output_label, output_confidence])
|
44 |
|
45 |
# 讛砖拽转 讛诪诪砖拽
|
46 |
demo.launch()
|