Spaces:
Runtime error
Runtime error
File size: 1,069 Bytes
a7eca0b 1a67d75 a7eca0b 1a67d75 a7eca0b 1a67d75 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | import requests
# Thay <your-hf-space-url> bằng URL thực tế của bạn sau khi deploy lên Hugging Face Spaces
url = 'https://<your-hf-space-url>.hf.space/inference'
video_path = '/path/to/your_video.mp4' # Thay đổi đường dẫn tới video của bạn
# Các trường form data
data = {
'model_name': 'spoter', # Hoặc 'sl_gcn', 'dsta_slr' tùy vào mô hình bạn muốn sử dụng
'output_dir': 'custom_output_folder' # Thư mục để lưu kết quả, có thể tùy chỉnh
}
# Tệp video được tải lên
files = {
'file': open(video_path, 'rb')
}
try:
# Gửi request POST tới API
response = requests.post(url=url, data=data, files=files)
# Kiểm tra mã trạng thái HTTP
response.raise_for_status()
# In kết quả phản hồi dưới dạng JSON
print(response.json())
except requests.exceptions.HTTPError as http_err:
print(f'HTTP error occurred: {http_err}') # Ví dụ: 400, 500
except Exception as err:
print(f'Other error occurred: {err}') # Các lỗi khác
|