L2Cs-Net
Use L2Cs-Net gaze detection model through our Serverless Hosted API
Code sample
curl --location 'https://serverless.roboflow.com/gaze/gaze_detection' \
--header 'Content-Type: application/json' \
--data '{
"api_key": "YOUR_API_KEY",
"image": {"type": "url", "value": "https://media.roboflow.com/inference/man.jpg"}
}'pip install inference-sdkimport os
import urllib.request
from inference_sdk import InferenceHTTPClient
image_url = "https://media.roboflow.com/inference/man.jpg"
image_path = "man.jpg"
urllib.request.urlretrieve(image_url, image_path)
client = InferenceHTTPClient(
api_url="https://serverless.roboflow.com",
api_key=os.getenv("API_KEY"),
).select_api_v1()
result = client.detect_gazes(image_path)
for prediction in result[0]["predictions"]:
face = prediction["face"]
yaw = prediction["yaw"]
pitch = prediction["pitch"]
print(f"Face at ({face['x']}, {face['y']}) - yaw: {yaw:.3f}, pitch: {pitch:.3f}")Last updated
Was this helpful?