gaze-emotion-api / test_api.py
pranavinani
modified test_api
169a6ba
raw
history blame contribute delete
564 Bytes
import requests
import json
# Test the API
def test_api():
# Test deployed Hugging Face Space
url = "https://pranavinani-gaze-emotion-api.hf.space/analyze"
with open("image.png", "rb") as f:
files = {"file": ("image.png", f, "image/png")}
response = requests.post(url, files=files)
if response.status_code == 200:
result = response.json()
print(json.dumps(result, indent=2))
else:
print(f"Error: {response.status_code}")
print(response.text)
if __name__ == "__main__":
test_api()