Face Sentiment

Introduction

Face Sentiment api allow you to detect sentiment of person within the image. Along with sentiment other characteristics like Age , Face Cordinate , Gender , Emotion , Race

Facial Sentiment

Endpoint

Post
   https://api.oyyi.xyz/v1/ml/face-sentiment

Content-Type: multipart/form-data

Parameters

  • file required

    Image file containing face that need to be analyzed for facial sentiments
    • Type: File
    • Size: Max File Size Allowed 100MB
  • full

    Setting this value as true will return full detail version for facial sentiment
    • Type: only Allowed Value is true
    • Default: it is set to false

Example

Sample Image used

Python
import requestsurl = $BASE_URL/ml/face-sentimenttoken = 'your_bearer_token_here'headers = {'Authorization': f'Bearer {token}'}files = {'file': open('example_file.jpg', 'rb')}response = requests.post(url,params=params, headers=headers, files=files)print(response.text)
Javascript
const axios = require('axios');const url = $BASE_URL/ml/face-sentiment;const token = 'your_bearer_token_here';const formData = new FormData();formData.append('file', YOUR FILE);formData.append('full', 'true');const config = {  headers: {    'Authorization': `Bearer ${token}`,    'Content-Type': 'multipart/form-data'  }};axios.post(url, formData, config)  .then(response => console.log(response.data))  .catch(error => console.error(error));
Dart
import 'dart:io';import 'package:http/http.dart' as http;void main() async {   final url = Uri.parse('$BASE_URL/ml/face-sentiment');  final headers = {'Content-Type': 'multipart/form-data'};  final request = http.MultipartRequest('POST', url);  request.headers.addAll(headers);  request.fields['full'] = 'true';  request.files.add(await http.MultipartFile.fromPath('file', '/path/to/file'));  final response = await request.send();}
Laravel
use Illuminate\Http\Client\Response;use Illuminate\Support\Facades\Http;$url = '$BASE_URL/ml/face-sentiment';$token = 'your_bearer_token_here';$response = Http::withHeaders([    'Authorization' => 'Bearer ' . $token,])->attach('file', $file_path)->post($url);if ($response->successful()) {    $data = $response->json();} else {m    $message = $response->json()['message']m;}
Curl
curl -X POST \  -H 'Authorization: Bearer your_bearer_token_here' \  -F 'file=@/path/to/your/file' \  $BASE_URL/ml/face-sentiment

Response

Default
{  "data": {    "age": 25,    "face_region": {      "h": 89,      "w": 89,      "x": 1087,      "y": 375    },    "gender": "Man",    "major_emotion": "sad",    "major_race": "white"  }}
With Full Param
{  "data": {    "age": 25,    "emotion": {      "angry": 0.541308,      "disgust": 0.000095,      "fear": 0.006898,      "happy": 0.040186,      "neutral": 0.001107,      "sad": 99.410409,      "surprise": 0    },    "face_region": {      "h": 89,      "w": 89,      "x": 1087,      "y": 375    },    "gender": "Man",    "major_emotion": "sad",    "major_race": "white",    "race": {      "asian": 0.083637,      "black": 0.000109,      "indian": 0.009359,      "latino hispanic": 0.027481,      "middle eastern": 0.157583,      "white": 99.721831    }  }}