-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (23 loc) · 824 Bytes
/
main.py
File metadata and controls
33 lines (23 loc) · 824 Bytes
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
33
import json
import base64
import pandas
import time
from api import detect_humans, get_results
def main():
with open("photo.jpg", "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode("utf8")
# TODO handle request fail scenarios
response = detect_humans(encoded_string)
job_id = response['data']['job_id']
status = 0
while not status == 200:
print("Checking for results...")
time.sleep(0.1)
response = get_results(job_id)
status = response['status']
print(status == 200 and "Results found!" or "No results yet")
data = json.dumps(response['data'])
pandas.read_json(path_or_buf=data, orient='split').to_excel("output.xlsx", index=False)
print("Excel file created!")
if __name__ == '__main__':
main()