benjaminStreltzin commited on
Commit
93c87bc
verified
1 Parent(s): 116dd4a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -20
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
- animation.visible = True # 讛专讗讛 讗转 讛讗谞讬诪爪讬讛
14
- label, confidence = model.predict(image)
15
- result = "AI image" if label == 1 else "Real image"
16
- animation.visible = False # 讛住转专 讗转 讛讗谞讬诪爪讬讛
17
- return result, f"Confidence: {confidence:.2f}%"
18
-
19
-
20
- # Define the Gradio interface
21
- demo = gr.Interface(
22
- fn=predict,
23
- inputs=gr.Image(type="pil"),
24
- outputs=[gr.Textbox(), gr.Textbox()],
25
- title="Vision Transformer Model",
26
- description="Upload an image to classify it using the Vision Transformer model.",
27
- live=True, # 诪讗驻砖专 讞讬讝讜讬 诪讬讬讚讬
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__":