# Object Detection

Roboflow Hosted API का उपयोग करके object detection inference चलाने के कई तरीके हैं। आप हमारे विभिन्न SDKs में से किसी एक का उपयोग कर सकते हैं, या हमारे hosted endpoint पर REST request भेज सकते हैं।

{% tabs %}
{% tab title="Python" %}
Dependencies install करने के लिए, `pip install inference-sdk`.

```python
# import the inference-sdk
from inference_sdk import InferenceHTTPClient

CLIENT = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key="API_KEY"
)

result = CLIENT.infer(your_image.jpg, model_id="football-players-detection-3zvbc/12")
```

{% endtab %}

{% tab title="cURL" %}
**Linux या MacOS**

नाम की एक local file के लिए JSON predictions प्राप्त करना `YOUR_IMAGE.jpg`:

```bash
base64 YOUR_IMAGE.jpg | curl -d @- \
"https://serverless.roboflow.com/your-model/42?api_key=YOUR_KEY"
```

इसके URL के माध्यम से web पर कहीं और host की गई image पर inference करना (URL को [URL encode करना न भूलें](https://www.urlencoder.org/)):

```bash
curl -X POST "https://serverless.roboflow.com/your-model/42?\
api_key=YOUR_KEY&\
image=https%3A%2F%2Fi.imgur.com%2FPEEvqPN.png"
```

**Windows**

आपको install करना होगा [Windows के लिए curl](https://curl.se/windows/) और [Windows के लिए GNU का base64 tool](http://gnuwin32.sourceforge.net/packages/coreutils.htm). ऐसा करने का सबसे आसान तरीका है [Windows installer के लिए git](https://git-scm.com/downloads) जिसमें `curl` और `base64` command line tools भी शामिल होते हैं जब आप installation के दौरान "Use Git and optional Unix tools from the Command Prompt" चुनते हैं।

फिर आप ऊपर वाले समान commands का उपयोग कर सकते हैं।
{% endtab %}

{% tab title="Javascript" %}
**Node.js**

हम उपयोग कर रहे हैं [axios](https://github.com/axios/axios) इस उदाहरण में POST request करने के लिए, इसलिए पहले चलाएँ `npm install axios` dependency install करने के लिए।

**Local Image पर inference करना**

```javascript
const axios = require("axios");
const fs = require("fs");

const image = fs.readFileSync("YOUR_IMAGE.jpg", {
    encoding: "base64"
});

axios({
    method: "POST",
    url: "https://serverless.roboflow.com/your-model/42",
    params: {
        api_key: "YOUR_KEY"
    },
    data: image,
    headers: {
        "Content-Type": "application/x-www-form-urlencoded"
    }
})
.then(function(response) {
    console.log(response.data);
})
.catch(function(error) {
    console.log(error.message);
});
```

**URL के माध्यम से कहीं और host की गई image पर inference करना**

```javascript
const axios = require("axios");

axios({
    method: "POST",
    url: "https://serverless.roboflow.com/your-model/42",
    params: {
        api_key: "YOUR_KEY",
        image: "https://i.imgur.com/PEEvqPN.png"
    }
})
.then(function(response) {
    console.log(response.data);
})
.catch(function(error) {
    console.log(error.message);
});
```

**Web**

हमारे पास realtime on-device inference उपलब्ध है `roboflow.js`के माध्यम से; देखें [दस्तावेज़ यहाँ](/roboflow/roboflow-hi/deploy/sdks/web-browser.md).
{% endtab %}

{% tab title="Swift/iOS" %}
**Swift**

**Local Image पर inference करना**

```swift
import UIKit

// Image लोड करें और Base64 में कन्वर्ट करें
let image = UIImage(named: "your-image-path") // अपलोड करने के लिए image का path, उदाहरण: image.jpg
let imageData = image?.jpegData(compressionQuality: 1)
let fileContent = imageData?.base64EncodedString()
let postData = fileContent!.data(using: .utf8)

// API_KEY, Model, और Model Version के साथ Inference Server Request initialize करें
var request = URLRequest(url: URL(string: "https://serverless.roboflow.com/your-model/your-model-version?api_key=YOUR_APIKEY&name=YOUR_IMAGE.jpg")!,timeoutInterval: Double.infinity)
request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
request.httpBody = postData

// Post Request execute करें
URLSession.shared.dataTask(with: request, completionHandler: { data, response, error in
    
    // Response को String में parse करें
    guard let data = data else {
        print(String(describing: error))
        return
    }
    
    // Response String को Dictionary में convert करें
    do {
        let dict = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
    } catch {
        print(error.localizedDescription)
    }
    
    // String response print करें
    print(String(data: data, encoding: .utf8)!)
}).resume()
```

**Objective C**

[Objective-C snippet request करने के लिए यहाँ क्लिक करें।](https://app.roboflow.com/request/snippet.inference-objc)
{% endtab %}

{% tab title="Android" %}
**Kotlin**

**Local Image पर inference करना**

```kotlin
import java.io.*
import java.net.HttpURLConnection
import java.net.URL
import java.nio.charset.StandardCharsets
import java.util.*

fun main() {
    // Image Path प्राप्त करें
    val filePath = System.getProperty("user.dir") + System.getProperty("file.separator") + "YOUR_IMAGE.jpg"
    val file = File(filePath)

    // Base 64 Encode
    val encodedFile: String
    val fileInputStreamReader = FileInputStream(file)
    val bytes = ByteArray(file.length().toInt())
    fileInputStreamReader.read(bytes)
    encodedFile = String(Base64.getEncoder().encode(bytes), StandardCharsets.US_ASCII)
    val API_KEY = "" // आपका API Key
    val MODEL_ENDPOINT = "dataset/v" // model endpoint सेट करें (Dataset URL में पाया जाता है)

    // URL construct करें
    val uploadURL ="https://serverless.roboflow.com/" + MODEL_ENDPOINT + "?api_key=" + API_KEY + "&name=YOUR_IMAGE.jpg";

    // Http Request
    var connection: HttpURLConnection? = null
    try {
        // URL से connection configure करें
        val url = URL(uploadURL)
        connection = url.openConnection() as HttpURLConnection
        connection.requestMethod = "POST"
        connection.setRequestProperty("Content-Type",
                "application/x-www-form-urlencoded")
        connection.setRequestProperty("Content-Length",
                Integer.toString(encodedFile.toByteArray().size))
        connection.setRequestProperty("Content-Language", "en-US")
        connection.useCaches = false
        connection.doOutput = true

        //Request भेजें
        val wr = DataOutputStream(
                connection.outputStream)
        wr.writeBytes(encodedFile)
        wr.close()

        // Response प्राप्त करें
        val stream = connection.inputStream
        val reader = BufferedReader(InputStreamReader(stream))
        var line: String?
        while (reader.readLine().also { line = it } != null) {
            println(line)
        }
        reader.close()
    } catch (e: Exception) {
        e.printStackTrace()
    } finally {
        connection?.disconnect()
    }
}
main()
```

**URL के माध्यम से कहीं और host की गई image पर inference करना**

```kotlin
import java.io.BufferedReader
import java.io.DataOutputStream
import java.io.InputStreamReader
import java.net.HttpURLConnection
import java.net.URL
import java.net.URLEncoder

fun main() {
    val imageURL = "https://i.imgur.com/PEEvqPN.png" // Image URL बदलें
    val API_KEY = "" // आपका API Key
    val MODEL_ENDPOINT = "dataset/v" // model endpoint सेट करें

    // Upload URL
    val uploadURL = "https://serverless.roboflow.com/" + MODEL_ENDPOINT + "?api_key=" + API_KEY + "&image=" + URLEncoder.encode(imageURL, "utf-8");

    // Http Request
    var connection: HttpURLConnection? = null
    try {
        // URL से connection configure करें
        val url = URL(uploadURL)
        connection = url.openConnection() as HttpURLConnection
        connection.requestMethod = "POST"
        connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded")
        connection.setRequestProperty("Content-Length", Integer.toString(uploadURL.toByteArray().size))
        connection.setRequestProperty("Content-Language", "en-US")
        connection.useCaches = false
        connection.doOutput = true

        // Request भेजें
        val wr = DataOutputStream(connection.outputStream)
        wr.writeBytes(uploadURL)
        wr.close()

        // Response प्राप्त करें
        val stream = URL(uploadURL).openStream()
        val reader = BufferedReader(InputStreamReader(stream))
        var line: String?
        while (reader.readLine().also { line = it } != null) {
            println(line)
        }
        reader.close()
    } catch (e: Exception) {
        e.printStackTrace()
    } finally {
        connection?.disconnect()
    }
}

main()
```

**Java**

**Local Image पर inference करना**

```java
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class InferenceLocal {
    public static void main(String[] args) throws IOException {
        // Image Path प्राप्त करें
        String filePath = System.getProperty("user.dir") + System.getProperty("file.separator") + "YOUR_IMAGE.jpg";
        File file = new File(filePath);

        // Base 64 Encode
        String encodedFile;
        FileInputStream fileInputStreamReader = new FileInputStream(file);
        byte[] bytes = new byte[(int) file.length()];
        fileInputStreamReader.read(bytes);
        encodedFile = new String(Base64.getEncoder().encode(bytes), StandardCharsets.US_ASCII);

        String API_KEY = ""; // आपका API Key
        String MODEL_ENDPOINT = "dataset/v"; // model endpoint

        // URL construct करें
        String uploadURL = "https://serverless.roboflow.com/" + MODEL_ENDPOINT + "?api_key=" + API_KEY
                + "&name=YOUR_IMAGE.jpg";

        // Http Request
        HttpURLConnection connection = null;
        try {
            // URL से connection configure करें
            URL url = new URL(uploadURL);
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

            connection.setRequestProperty("Content-Length", Integer.toString(encodedFile.getBytes().length));
            connection.setRequestProperty("Content-Language", "en-US");
            connection.setUseCaches(false);
            connection.setDoOutput(true);

            // Request भेजें
            DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
            wr.writeBytes(encodedFile);
            wr.close();

            // Response प्राप्त करें
            InputStream stream = connection.getInputStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }
            reader.close();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (connection != null) {
                connection.disconnect();
            }
        }

    }

}
```

**URL के माध्यम से कहीं और host की गई image पर inference करना**

```java
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

public class InferenceHosted {
    public static void main(String[] args) {
        String imageURL = "https://i.imgur.com/PEEvqPN.png"; // Image URL बदलें
        String API_KEY = ""; // आपका API Key
        String MODEL_ENDPOINT = "dataset/v"; // model endpoint

        // Upload URL
        String uploadURL = "https://serverless.roboflow.com/" + MODEL_ENDPOINT + "?api_key=" + API_KEY + "&image="
                + URLEncoder.encode(imageURL, StandardCharsets.UTF_8);

        // Http Request
        HttpURLConnection connection = null;
        try {
            // URL से connection configure करें
            URL url = new URL(uploadURL);
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

            connection.setRequestProperty("Content-Length", Integer.toString(uploadURL.getBytes().length));
            connection.setRequestProperty("Content-Language", "en-US");
            connection.setUseCaches(false);
            connection.setDoOutput(true);

            // Request भेजें
            DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
            wr.writeBytes(uploadURL);
            wr.close();

            // Response प्राप्त करें
            InputStream stream = new URL(uploadURL).openStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }
            reader.close();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (connection != null) {
                connection.disconnect();
            }
        }
    }
}
```

{% endtab %}

{% tab title="Ruby" %}
**Gemfile**

{% code title="Gemfile" %}

```ruby
source "https://rubygems.org"

gem "httparty", "~> 0.18.1"
gem "base64", "~> 0.1.0"
gem "cgi", "~> 0.2.1"
```

{% endcode %}

**Gemfile.lock**

{% code title="Gemfile.lock" %}

```ruby
GEM
  remote: https://rubygems.org/
  specs:
    base64 (0.1.0)
    cgi (0.2.1)
    httparty (0.18.1)
      mime-types (~> 3.0)
      multi_xml (>= 0.5.2)
    mime-types (3.3.1)
      mime-types-data (~> 3.2015)
    mime-types-data (3.2021.0225)
    multi_xml (0.6.0)

PLATFORMS
  x64-mingw32
  x86_64-linux

DEPENDENCIES
  base64 (~> 0.1.0)
  cgi (~> 0.2.1)
  httparty (~> 0.18.1)

BUNDLED WITH
   2.2.15
```

{% endcode %}

**Local Image पर inference करना**

```ruby
require 'base64'
require 'httparty'

encoded = Base64.encode64(File.open("YOUR_IMAGE.jpg", "rb").read)
model_endpoint = "dataset/v" # model endpoint सेट करें
api_key = "" # आपका API KEY यहाँ

params = "?api_key=" + api_key
+ "&name=YOUR_IMAGE.jpg"

response = HTTParty.post(
    "https://serverless.roboflow.com/" + model_endpoint + params,
    body: encoded, 
    headers: {
    'Content-Type' => 'application/x-www-form-urlencoded',
    'charset' => 'utf-8'
  })

  puts response

 
```

**URL के माध्यम से कहीं और host की गई image पर inference करना**

```ruby
require 'httparty'
require 'cgi'

model_endpoint = "dataset/v" # model endpoint सेट करें
api_key = "" # आपका API KEY यहाँ
img_url = "https://i.imgur.com/PEEvqPN.png" # URL construct करें

img_url = CGI::escape(img_url)

params =  "?api_key=" + api_key + "&image=" + img_url

response = HTTParty.post(
    "https://serverless.roboflow.com/" + model_endpoint + params,
    headers: {
    'Content-Type' => 'application/x-www-form-urlencoded',
    'charset' => 'utf-8'
  })

puts response
```

{% endtab %}

{% tab title="PHP" %}
**Local Image पर inference करना**

```php
<?php

// Image को Base 64 Encode करें
$data = base64_encode(file_get_contents("YOUR_IMAGE.jpg"));

$api_key = ""; // API Key सेट करें
$model_endpoint = "dataset/v"; // model endpoint सेट करें (Dataset URL में पाया जाता है)

// Http Request के लिए URL
$url = "https://serverless.roboflow.com/" . $model_endpoint
. "?api_key=" . $api_key
. "&name=YOUR_IMAGE.jpg";

// Http request सेटअप + भेजें
$options = array(
  'http' => array (
    'header' => "Content-type: application/x-www-form-urlencoded\r\n",
    'method'  => 'POST',
    'content' => $data
  ));

$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;
?>
```

**URL के माध्यम से कहीं और host की गई image पर inference करना**

```php
<?php

$api_key = ""; // API Key सेट करें
$model_endpoint = "dataset/v"; // model endpoint सेट करें (Dataset URL में पाया जाता है)
$img_url = "https://i.imgur.com/PEEvqPN.png";

// Http Request के लिए URL
$url =  "https://serverless.roboflow.com/" . $model_endpoint
. "?api_key=" . $api_key
. "&image=" . urlencode($img_url);

// Http request सेटअप + भेजें
$options = array(
  'http' => array (
    'header' => "Content-type: application/x-www-form-urlencoded\r\n",
    'method'  => 'POST'
  ));

$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;
?>
```

{% endtab %}

{% tab title="Go" %}
**Local Image पर inference करना**

```go
package main

import (
    "bufio"
    "encoding/base64"
    "fmt"
    "io/ioutil"
    "os"
	"net/http"
	"strings"
)

func main() {
	api_key := ""  // आपका API Key
	model_endpoint := "dataset/v" // model endpoint सेट करें

    // Disk पर file खोलें।
    f, _ := os.Open("YOUR_IMAGE.jpg")

    // पूरी JPG को byte slice में पढ़ें।
    reader := bufio.NewReader(f)
    content, _ := ioutil.ReadAll(reader)

    // base64 के रूप में encode करें।
    data := base64.StdEncoding.EncodeToString(content)
	uploadURL := "https://serverless.roboflow.com/" + model_endpoint + "?api_key=" + api_key + "&name=YOUR_IMAGE.jpg"

	req, _ := http.NewRequest("POST", uploadURL, strings.NewReader(data))
    req.Header.Set("Accept", "application/json")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

   	bytes, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(bytes))

}
```

**URL के माध्यम से कहीं और host की गई image पर inference करना**

```go
package main

import (
    "fmt"
	"net/http"
	"net/url"
  "io/ioutil"
)

func main() {
	api_key := ""  // आपका API Key
	model_endpoint := "dataset/v" // model endpoint सेट करें
	img_url := "https://i.ibb.co/jzr27x0/YOUR-IMAGE.jpg"


	uploadURL := "https://serverless.roboflow.com/" + model_endpoint + "?api_key=" + api_key + "&image=" + url.QueryEscape(img_url)

	req, _ := http.NewRequest("POST", uploadURL, nil)
    req.Header.Set("Accept", "application/json")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

   	bytes, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(bytes))


}
```

{% endtab %}

{% tab title=".NET" %}
**Local Image पर inference करना**

```csharp
using System;
using System.IO;
using System.Net;
using System.Text;

namespace InferenceLocal
{
    class InferenceLocal
    {

        static void Main(string[] args)
        {
            byte[] imageArray = System.IO.File.ReadAllBytes(@"YOUR_IMAGE.jpg");
            string encoded = Convert.ToBase64String(imageArray);
            byte[] data = Encoding.ASCII.GetBytes(encoded);
            string API_KEY = ""; // आपका API Key
            string MODEL_ENDPOINT = "dataset/v"; // model endpoint सेट करें

            // URL construct करें
            string uploadURL =
                    "https://serverless.roboflow.com/" + MODEL_ENDPOINT + "?api_key=" + API_KEY
                + "&name=YOUR_IMAGE.jpg";

            // Service Request Config
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            // Request configure करें
            WebRequest request = WebRequest.Create(uploadURL);
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = data.Length;

            // Data लिखें
            using (Stream stream = request.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }

            // Response प्राप्त करें
            string responseContent = null;
            using (WebResponse response = request.GetResponse())
            {
                using (Stream stream = response.GetResponseStream())
                {
                    using (StreamReader sr99 = new StreamReader(stream))
                    {
                        responseContent = sr99.ReadToEnd();
                    }
                }
            }

            Console.WriteLine(responseContent);

        }
    }
}
```

**URL के माध्यम से कहीं और host की गई image पर inference करना**

```csharp
using System;
using System.IO;
using System.Net;
using System.Web;

namespace InferenceHosted
{
    class InferenceHosted
    {
        static void Main(string[] args)
        {
            string API_KEY = ""; // आपका API Key
            string imageURL = "https://i.ibb.co/jzr27x0/YOUR-IMAGE.jpg";
            string MODEL_ENDPOINT = "dataset/v"; // model endpoint सेट करें

            // URL construct करें
            string uploadURL =
                    "https://serverless.roboflow.com/" + MODEL_ENDPOINT
                    + "?api_key=" + API_KEY
                    + "&image=" + HttpUtility.UrlEncode(imageURL);

            // Service Point Config
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            // Http Request configure करें
            WebRequest request = WebRequest.Create(uploadURL);
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = 0;

            // Response प्राप्त करें
            string responseContent = null;
            using (WebResponse response = request.GetResponse())
            {
                using (Stream stream = response.GetResponseStream())
                {
                    using (StreamReader sr99 = new StreamReader(stream))
                    {
                        responseContent = sr99.ReadToEnd();
                    }
                }
            }

            Console.WriteLine(responseContent);

        }
    }
}
```

{% endtab %}

{% tab title="More" %}
{% hint style="info" %}
हमारे AI-powered chatbot Lenny से पूछकर अपने लिए code sample बनवाने की कोशिश करें!
{% endhint %}
{% endtab %}
{% endtabs %}

## API Reference

### URL

<mark style="color:green;">`POST`</mark> `https://serverless.roboflow.com/:projectId/:versionNumber`

<table><thead><tr><th width="157">Name</th><th width="101">Type</th><th>Description</th></tr></thead><tbody><tr><td>projectId</td><td>string</td><td>dataset नाम का URL-safe version। आप इसे web UI में मुख्य project view के URL को देखकर, या model training के बाद अपने dataset version के train results section में "Get curl command" बटन पर क्लिक करके पा सकते हैं।</td></tr><tr><td>version</td><td>number</td><td>अपने dataset के version की पहचान करने वाला version number</td></tr></tbody></table>

{% hint style="info" %}
देखें कि अपना project ID और version number कैसे प्राप्त करें [यहाँ](https://docs.roboflow.com/api-reference/workspace-and-project-ids#how-to-retrieve-a-project-id-and-version-number).
{% endhint %}

REST request के माध्यम से Serverless Hosted API पर image भेजने के दो तरीके हैं:

* एक `base64` encoded image को `POST` request body
* के साथ एक image file का URL भेजें `image` URL query
  * उदाहरण: `https://serverless.roboflow.com/:datasetSlug/:versionNumber?image=https://imageurl.com`

#### Query Parameters

<table><thead><tr><th width="120">Name</th><th width="106">Type</th><th>Description</th></tr></thead><tbody><tr><td>image</td><td>string</td><td>जो image जोड़नी है उसका URL। उपयोग करें यदि आपकी image कहीं और hosted है। (जब आप request body में base64 encoded image POST नहीं करते हैं, तब आवश्यक।)<br><br><strong>नोट:</strong> इसे URL-encode करना न भूलें।</td></tr><tr><td>classes</td><td>string</td><td>predictions को केवल कुछ निश्चित classes तक सीमित करें। comma-separated string के रूप में दें।<br><br><strong>उदाहरण:</strong> dog,cat<br><br><strong>Default:</strong> मौजूद नहीं (सभी classes दिखाएँ)</td></tr><tr><td>overlap</td><td>number</td><td><p>अधिकतम प्रतिशत (0-100 के पैमाने पर) जिस तक समान class के bounding box predictions को एक single box में combine करने से पहले overlap करने की अनुमति है।</p><p><strong>Default:</strong> 30</p><p>इस parameter का RF-DETR models पर कोई प्रभाव नहीं पड़ता।</p></td></tr><tr><td>confidence</td><td>number</td><td><p>0-100 के पैमाने पर returned predictions के लिए एक threshold। कम संख्या अधिक predictions लौटाएगी। अधिक संख्या कम high-certainty predictions लौटाएगी।</p><p><strong>Default:</strong> 40</p></td></tr><tr><td>stroke</td><td>number</td><td><p>predictions के चारों ओर प्रदर्शित bounding box की चौड़ाई (pixels में) (केवल तब प्रभावी होती है जब <code>format</code> है <code>image</code>).</p><p><strong>Default:</strong> 1</p></td></tr><tr><td>लेबल</td><td>बूलियन</td><td><p>क्या predictions पर text labels दिखाने हैं या नहीं (सिर्फ तब प्रभावी होता है जब <code>format</code> है <code>image</code>).</p><p><strong>Default:</strong> false</p></td></tr><tr><td>format</td><td>string</td><td><p><strong>विकल्प:</strong></p><ul><li><strong>json:</strong> JSON predictions की एक array लौटाता है। (response format टैब देखें)।</li><li><strong>image:</strong> annotated predictions वाली एक image को binary blob के रूप में लौटाता है, एक <code>Content-Type</code> के <code>image/jpeg</code>.</li></ul><p><strong>डिफ़ॉल्ट</strong>: <code>json</code></p></td></tr><tr><td>api_key</td><td>string</td><td>आपकी API key (जो आपके workspace API settings page से प्राप्त होती है)</td></tr></tbody></table>

### Request Body

<table><thead><tr><th width="104">Type</th><th>Description</th></tr></thead><tbody><tr><td>string</td><td>एक base64 encoded image। (अनिवार्य जब आप query parameters में image URL नहीं देते)।</td></tr></tbody></table>

content type होना चाहिए `application/x-www-form-urlencoded` एक string body के साथ।

## Response Format

hosted API inference endpoint, साथ ही हमारे अधिकांश SDKs, एक `JSON` object लौटाते हैं जिसमें predictions की एक array होती है। हर prediction में निम्न properties होती हैं:

* `x` = detected object का horizontal center point
* `y` = detected object का vertical center point
* `width` = bounding box की width
* `height` = bounding box की height
* `class` = detected object का class label
* `confidence` = model का confidence कि detected object का label और position coordinates सही हैं

REST API से एक उदाहरण response object यहाँ है:

```json
{
    "predictions": [
        {
            "x": 189.5,
            "y": 100,
            "width": 163,
            "height": 186,
            "class": "helmet",
            "confidence": 0.544
        }
    ],
    "image": {
        "width": 2048,
        "height": 1371
    }
}
```

The `image` attribute में inference के लिए भेजी गई image की height और width होती है। bounding box calculations के लिए आपको इन मानों का उपयोग करना पड़ सकता है।

## Inference API JSON Output से Box बनाना

bounding boxes render करने के लिए frameworks और packages positional formats में अलग-अलग हो सकते हैं। response `JSON` object की properties को देखते हुए, bounding box हमेशा निम्न नियमों के किसी संयोजन का उपयोग करके बनाया जा सकता है:

* center point हमेशा (`x`,`y`)
* corner points `(x1, y1)` और `(x2, y2)` को इस प्रकार पाया जा सकता है:
  * `x1` = `x - (width/2)`
  * `y1` = `y - (height/2)`
  * `x2` = `x + (width/2)`
  * `y2` = `y + (height/2)`

corner points का तरीका एक सामान्य pattern है और इसे ऐसी libraries में देखा जाता है जैसे `Pillow` जब `box` object बनाया जाता है ताकि bounding boxes को किसी `Image`.

predictions के साथ काम करते समय मिली सभी detections पर iterate करना न भूलें `predictions`!

```python
# Pillow library से example box object
for bounding_box in detections:
    x1 = bounding_box['x'] - bounding_box['width'] / 2
    x2 = bounding_box['x'] + bounding_box['width'] / 2
    y1 = bounding_box['y'] - bounding_box['height'] / 2
    y2 = bounding_box['y'] + bounding_box['height'] / 2
    box = (x1, x2, y1, y2)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.roboflow.com/roboflow/roboflow-hi/deploy/serverless/object-detection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
