Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,26 +9,22 @@ theme = gr.themes.Base()
|
|
9 |
|
10 |
with gr.Blocks(theme=theme) as demo:
|
11 |
|
12 |
-
def predict(image: Image.Image):
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
)
|
29 |
-
|
30 |
-
# Add video component
|
31 |
-
animation = gr.Video("https://cdn-uploads.huggingface.co/production/uploads/66d6f1b3b50e35e1709bfdf7/x7Ud8PO9QPfmrTvBVcCKE.mp4", visible=True) # 讛讻谞讬住讬 讗转 讛-URL 讛谞讻讜谉
|
32 |
|
33 |
# Launch the Gradio interface
|
34 |
if __name__ == "__main__":
|
|
|
9 |
|
10 |
with gr.Blocks(theme=theme) as demo:
|
11 |
|
12 |
+
def predict(image: Image.Image):
|
13 |
+
animation.visible = True # Show the animation
|
14 |
+
label, confidence = model.predict(image)
|
15 |
+
result = "AI image" if label == 1 else "Real image"
|
16 |
+
animation.visible = False # Hide the animation
|
17 |
+
return result, f"Confidence: {confidence:.2f}%"
|
18 |
+
|
19 |
+
# Define the Gradio interface
|
20 |
+
gr.Interface(
|
21 |
+
fn=predict,
|
22 |
+
inputs=gr.Image(type="pil"),
|
23 |
+
outputs=[gr.Textbox(), gr.Textbox()],
|
24 |
+
title="Vision Transformer Model",
|
25 |
+
description="Upload an image to classify it using the Vision Transformer model.",
|
26 |
+
live=True, # Allows immediate prediction
|
27 |
+
)
|
|
|
|
|
|
|
|
|
28 |
|
29 |
# Launch the Gradio interface
|
30 |
if __name__ == "__main__":
|