litav commited on
Commit
93ac46b
verified
1 Parent(s): 439f2b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -6,11 +6,12 @@ from vit_model_test import CustomModel
6
  model = CustomModel()
7
 
8
  def predict(image: Image.Image):
9
-
10
  label, confidence = model.predict(image)
11
  result = "AI image" if label == 1 else "Real image"
 
12
  return result, f"Confidence: {confidence:.2f}%"
13
-
14
 
15
  # Define the Gradio interface
16
  demo = gr.Interface(
@@ -18,9 +19,13 @@ demo = gr.Interface(
18
  inputs=gr.Image(type="pil"),
19
  outputs=[gr.Textbox(), gr.Textbox()],
20
  title="Vision Transformer Model",
21
- description="Upload an image to classify it using the Vision Transformer model."
 
22
  )
23
 
 
 
24
 
25
  # Launch the Gradio interface
26
- demo.launch()
 
 
6
  model = CustomModel()
7
 
8
  def predict(image: Image.Image):
9
+ animation.visible = True # 讛专讗讛 讗转 讛讗谞讬诪爪讬讛
10
  label, confidence = model.predict(image)
11
  result = "AI image" if label == 1 else "Real image"
12
+ animation.visible = False # 讛住转专 讗转 讛讗谞讬诪爪讬讛
13
  return result, f"Confidence: {confidence:.2f}%"
14
+
15
 
16
  # Define the Gradio interface
17
  demo = gr.Interface(
 
19
  inputs=gr.Image(type="pil"),
20
  outputs=[gr.Textbox(), gr.Textbox()],
21
  title="Vision Transformer Model",
22
+ description="Upload an image to classify it using the Vision Transformer model.",
23
+ live=True, # 诪讗驻砖专 讞讬讝讜讬 诪讬讬讚讬
24
  )
25
 
26
+ # Add video component
27
+ animation = gr.Video("https://cdn-uploads.huggingface.co/production/uploads/66d6f1b3b50e35e1709bfdf7/x7Ud8PO9QPfmrTvBVcCKE.mp4", visible=False) # 讛讻谞讬住讬 讗转 讛-URL 讛谞讻讜谉
28
 
29
  # Launch the Gradio interface
30
+ if __name__ == "__main__":
31
+ demo.launch()