Object Detection

Introduction

Object Detection is part of Machine Learning , in which we use different algorithm to detect object in Image, Or Video files. Our algorithm can detect around 10K+ different objects.

Object Detection Example

Endpoint

Post
   https://api.oyyi.xyz/v1/ml/object-detection

Content-Type: multipart/form-data

Parameters

  • file Required

    File containing object need to pass to request
    • Type: File
      Maximum allowed sized for file is 100MB
  • mode

    Mode define how output result should be return to user regarding the detected object.
    • Type: string
    • Allowed: xywh, xywhn, xyxy, xyxyn
    • Default: xyxyn
  • threshold

    Threshold is number which defines confidence of object inside the image. Object with less confidence than threshold will get ignored in results
    • Type: number
    • Allowed: number between 1 to 100
    • Default: 40

Example

Sample Image used

Python
import requestsurl = $BASE_URL/ml/object-detectiontoken = 'your_bearer_token_here'headers = {'Authorization': f'Bearer {token}'}files = {'file': open('person.jpg', 'rb')}response = requests.post(url, headers=headers, files=files)print(response.text)
Javascript
const axios = require('axios');const url = $BASE_URL/ml/object-detection;const token = 'your_bearer_token_here';const formData = new FormData();formData.append('file', YOUR FILE);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 {  var url = Uri.parse($BASE_URL/optimize);  var token = 'your_bearer_token_here';  var request = http.MultipartRequest('POST', url)    ..headers['Authorization'] = 'Bearer $token'    ..files.add(await http.MultipartFile.fromPath('file', 'person.jpg'));  var response = await request.send();  print(await response.stream.bytesToString());}
Laravel
use Illuminate\Http\Client\Response;use Illuminate\Support\Facades\Http;$url = '$BASE_URL/ml/object-detection';$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'];}
Curl
curl -X POST \  -H 'Authorization: Bearer your_bearer_token_here' \  -F 'file=@/path/to/your/file' \  $BASE_URL/ml/object-detection

Response

xyxyn
{  "data": [    {      "class": 0,      "confidence": 0.9367442131,      "name": "person",      "xmax": 0.7731372118,      "xmin": 0.1024992168,      "ymax": 0.7416218519,      "ymin": 0.1403899938    },    {      "class": 16,      "confidence": 0.9351310134,      "name": "dog",      "xmax": 1,      "xmin": 0.0016319321,      "ymax": 1,      "ymin": 0.6291618943    },    {      "class": 2,      "confidence": 0.7377066612,      "name": "car",      "xmax": 0.9993353486,      "xmin": 0.7337724566,      "ymax": 0.6310616732,      "ymin": 0.4480176568    }  ],}
xywh
{  "data": [    {      "class": 0,      "confidence": 0.9367442131,      "height": 619.8700561523,      "name": "person",      "width": 460.728302002,      "xcenter": 300.7811279297,      "ycenter": 454.6770935059    },    {      "class": 16,      "confidence": 0.9351310134,      "height": 382.3341064453,      "name": "dog",      "width": 685.8788452148,      "xcenter": 344.0605773926,      "ycenter": 839.8329467773    },    {      "class": 2,      "confidence": 0.7377066612,      "height": 188.7183837891,      "name": "car",      "width": 182.4417114258,      "xcenter": 595.3225097656,      "ycenter": 556.2653808594    }  ],}
xywhn
{  "count": 3,  "data": [    {      "class": 0,      "confidence": 0.9367442131,      "height": 0.601231873,      "name": "person",      "width": 0.6706379652,      "xcenter": 0.4378182292,      "ycenter": 0.4410059154    },    {      "class": 16,      "confidence": 0.9351310134,      "height": 0.3708381355,      "name": "dog",      "width": 0.9983680248,      "xcenter": 0.5008159876,      "ycenter": 0.8145809174    },    {      "class": 2,      "confidence": 0.7377066612,      "height": 0.1830440164,      "name": "car",      "width": 0.265562892,      "xcenter": 0.866553843,      "ycenter": 0.5395396352    }  ],  "status": "done"}
xyxy
{  "count": 3,  "data": [    {      "class": 0,      "confidence": 0.9367442131,      "name": "person",      "xmax": 531.1452636719,      "xmin": 70.4169616699,      "ymax": 764.612121582,      "ymin": 144.7420806885    },    {      "class": 16,      "confidence": 0.9351310134,      "name": "dog",      "xmax": 687,      "xmin": 1.1211373806,      "ymax": 1031,      "ymin": 648.6658935547    },    {      "class": 2,      "confidence": 0.7377066612,      "name": "car",      "xmax": 686.5433959961,      "xmin": 504.1016845703,      "ymax": 650.6245727539,      "ymin": 461.9061889648    }  ],  "status": "done"}