Spaces:
Build error
Build error
Download clients.py from VitouPro/animal_classification: direct link, hf CLI and curl.
- Browser
- Download file 595 Bytes
-
https://huggingface.co/spaces/VitouPro/animal_classification/resolve/main/clients.py
- Command line
-
hf download hf://spaces/VitouPro/animal_classification/clients.py
-
curl -L -o clients.py https://huggingface.co/spaces/VitouPro/animal_classification/resolve/main/clients.py
595 Bytes
| from __future__ import print_function | |
| import requests | |
| import json | |
| import cv2 | |
| def send_request(img_input, url): | |
| addr = url | |
| # prepare headers for http request | |
| content_type = 'text' | |
| headers = {'content-type': content_type} | |
| # img = cv2.imread(r"C:\Users\soyvi\OneDrive\Pictures\O.1.jpg") | |
| img = img_input | |
| # encode image as jpeg | |
| _, img_encoded = cv2.imencode('.jpg', img) | |
| # send http request with image and receive response | |
| response = requests.post(addr, data=img_encoded.tostring(), headers=headers) | |
| result = json.loads(response.text) | |
| return result |