litav commited on
Commit
0ceff0a
verified
1 Parent(s): 5fc16ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -15
app.py CHANGED
@@ -1,15 +1,26 @@
1
- import requests
2
-
3
- def check_video_url(video_url):
4
- try:
5
- response = requests.head(video_url) # 诪讘爪注 讘拽砖转 HEAD 诇讘讚讜拽 讗转 讛-URL
6
- if response.status_code == 200:
7
- print("The video URL is valid and accessible.")
8
- else:
9
- print(f"Received status code: {response.status_code}. The video may not be accessible.")
10
- except requests.exceptions.RequestException as e:
11
- print(f"An error occurred: {e}")
12
-
13
- # 拽讬砖讜专 诇住专讟讜谉 诇讘讚讬拽讛
14
- video_url = "https://cdn-uploads.huggingface.co/production/uploads/66d6f1b3b50e35e1709bfdf7/x7Ud8PO9QPfmrTvBVcCKE.mp4"
15
- check_video_url(video_url)
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from PIL import Image
3
+ from vit_model_test import CustomModel
4
+
5
+ # Initialize the model
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(
17
+ fn=predict,
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()