Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,15 @@
|
|
| 1 |
-
import
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
# Define the Gradio interface
|
| 17 |
-
with gr.Blocks() as demo:
|
| 18 |
-
image_input = gr.Image(type="pil", label="Upload an image")
|
| 19 |
-
animation = gr.Video("https://cdn-uploads.huggingface.co/production/uploads/66d6f1b3b50e35e1709bfdf7/x7Ud8PO9QPfmrTvBVcCKE.mp4", visible=False)
|
| 20 |
-
output_label = gr.Textbox(label="Classification Result", interactive=False)
|
| 21 |
-
output_confidence = gr.Textbox(label="Confidence", interactive=False)
|
| 22 |
-
|
| 23 |
-
def show_animation(image):
|
| 24 |
-
return animation.update(visible=True), "", "" # 诇讛爪讬讙 讗转 讛讗谞讬诪爪讬讛
|
| 25 |
-
|
| 26 |
-
def hide_animation(image):
|
| 27 |
-
result, confidence = predict(image)
|
| 28 |
-
return animation.update(visible=False), result, confidence # 诇讛住转讬专 讗转 讛讗谞讬诪爪讬讛 讜诇讛讞讝讬专 讗转 讛转讜爪讗讜转
|
| 29 |
-
|
| 30 |
-
# 注讚讻讜谉 注诇 讛讗讬专讜注讬诐
|
| 31 |
-
image_input.change(show_animation, inputs=image_input, outputs=[animation, output_label, output_confidence])
|
| 32 |
-
image_input.submit(hide_animation, inputs=image_input, outputs=[output_label, output_confidence])
|
| 33 |
-
|
| 34 |
-
# Launch the Gradio interface
|
| 35 |
-
demo.launch()
|
|
|
|
| 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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|