import requests
import base64
from PIL import Image
from io import BytesIO
project_id = “drive-drowsiness-detection”
model_version = 2
confidence = 0.5
iou_thresh = 0.5
api_key = “”
image_url = “https://t3.ftcdn.net/jpg/02/76/37/14/360_F_276371400_t9dtc2OOXwcq7mEY1JTuNxdT06nf63Np.jpg”
res = requests.post(
f"https://detect.roboflow.com/{project_id}/{model_version}?api_key={api_key}&confidence={confidence}&overlap={iou_thresh}&image={image_url}",
)
predictions = res.json()
print(predictions)
There’s no PIL module and BytesIO. The other modules have ports, see the documentation. See our Image module for our Image library.
You can use the to_jpeg() in our Image module to convert an image to jpeg. Image objects all have buffer access so you can pass them base64 encoding.