-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLobe01.py
More file actions
25 lines (19 loc) · 795 Bytes
/
Lobe01.py
File metadata and controls
25 lines (19 loc) · 795 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
import base64
import requests
# Save string of image file path below
img_filepath = "C:\\Users\\Haznaranv\\Desktop\\Emociones\\Sonriendo\\images_5.jpg"
# Create base64 encoded string
with open(img_filepath, "rb") as f:
image_string = base64.b64encode(f.read()).decode("utf-8")
# Get response from POST request
response = requests.post(
url="http://localhost:38101/v1/predict/42853612-a8a7-4a22-aeb8-4f456abe2bd7",
json={"image": image_string},
)
data = response.json()
top_prediction = data["predictions"][0]
print(data)
print("======================================================")
# Print the top predicted label and its confidence
print("predicted label:\t{}\nconfidence:\t\t{}"
.format(top_prediction["label"], top_prediction["confidence"]))