> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/roboflow/roboflow-hi/deploy/serverless/classification.md).

# Classification

{% tabs %}
{% tab title="Python" %}
**स्थानीय और होस्टेड इमेज़ पर Infer करें**

dependencies install करने के लिए, `pip install inference-sdk`.

```python
from inference_sdk import InferenceHTTPClient

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

result = CLIENT.infer(your_image.jpg, model_id="vehicle-classification-eapcd/2")
```

{% endtab %}

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

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

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

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

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

axios({
    method: "POST",
    url: "https://classify.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);
});
```

{% endtab %}

{% tab title="Swift" %}
**base64 का उपयोग करके स्थानीय छवि अपलोड करना**

```swift
import UIKit

// Image load करें और Base64 में convert करें
let image = UIImage(named: "your-image-path") // upload करने के लिए 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://classify.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()
```

{% endtab %}
{% endtabs %}

## प्रतिक्रिया ऑब्जेक्ट प्रारूप

{% tabs %}
{% tab title="Single-Label Classification" %}
**Single-Label Classification**

होस्टेड API inference route एक लौटाता है `JSON` object लौटाते हैं जिसमें predictions की एक array होती है। प्रत्येक prediction में निम्न properties होती हैं:

* `समय` = छवि को संसाधित करने और पूर्वानुमान लौटाने में लगा कुल समय, सेकंड में
* `image` = एक ऑब्जेक्ट जो छवि के बारे में जानकारी रखता है `चौड़ाई` और `ऊँचाई`
  * `चौड़ाई` अनुमानित छवि की ऊँचाई
  * `ऊँचाई` = अनुमानित छवि की ऊँचाई
* `भविष्यवाणियाँ` = पूर्वानुमान के लिए सभी अनुमानित वर्गों और उनके संबंधित confidence मानों का संग्रह
  * `class` = वर्गीकरण का लेबल
  * `confidence` = छवि में पहचाने गए वर्गीकरण की वस्तुएँ होने के बारे में मॉडल का confidence
* `top` = सबसे अधिक confidence वाला अनुमानित वर्ग
* `confidence` = सबसे उच्च अनुमानित confidence score
* `image_path` = अनुमानित छवि का path
* `prediction_type` = अनुमान करने के लिए उपयोग किए गए मॉडल का प्रकार, `ClassificationModel` इस मामले में

{% code overflow="wrap" %}

```json
// एक उदाहरण JSON object
{
  "time": 0.19064618100037478,
  "image": {
    "width": 210,
    "height": 113
  },
  "predictions": [
    {
      "class": "real-image",
      "confidence": 0.7149
    },
    {
      "class": "illustration",
      "confidence": 0.2851
    }
  ],
  "top": "real-image",
  "confidence": 0.7149,
  "image_path": "/cropped-images-1.jpg",
  "prediction_type": "ClassificationModel"
}
```

{% endcode %}
{% endtab %}

{% tab title="Multi-Label Classification" %}
**Multi-Label Classification**

होस्टेड API inference route एक लौटाता है `JSON` object लौटाते हैं जिसमें predictions की एक array होती है। प्रत्येक prediction में निम्न properties होती हैं:

* `समय` = छवि को संसाधित करने और पूर्वानुमान लौटाने में लगा कुल समय, सेकंड में
* `image` = एक ऑब्जेक्ट जो छवि के बारे में जानकारी रखता है `चौड़ाई` और `ऊँचाई`
  * `चौड़ाई` अनुमानित छवि की ऊँचाई
  * `ऊँचाई` = अनुमानित छवि की ऊँचाई
* `भविष्यवाणियाँ` = पूर्वानुमान के लिए सभी अनुमानित वर्गों और उनके संबंधित confidence मानों का संग्रह
  * `class` = वर्गीकरण का लेबल
  * `confidence` = छवि में पहचाने गए वर्गीकरण की वस्तुएँ होने के बारे में मॉडल का confidence
* `predicted_classes` = मॉडल पूर्वानुमानों में लौटाए गए सभी वर्गीकरणों (labels/classes) की सूची रखने वाला एक array
* `image_path` = अनुमानित छवि का path
* `prediction_type` = अनुमान करने के लिए उपयोग किए गए मॉडल का प्रकार, `ClassificationModel` इस मामले में

<pre class="language-json" data-overflow="wrap"><code class="lang-json"><strong>// एक उदाहरण JSON object
</strong>{
  "time": 0.19291414400004214,
  "image": {
    "width": 113,
    "height": 210
  },
  "predictions": {
    "dent": {
      "confidence": 0.5253503322601318
    },
    "severe": {
      "confidence": 0.5804202556610107
    }
  },
  "predicted_classes": [
    "dent",
    "severe"
  ],
  "image_path": "/car-model-343.jpg",
  "prediction_type": "ClassificationModel"
}
</code></pre>

{% endtab %}
{% endtabs %}

## API Reference

## Inference API का उपयोग करना

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

आप सीधे अपने model endpoint पर एक base64 encoded image POST कर सकते हैं। या आप query string में parameter के रूप में एक URL पास कर सकते हैं यदि आपकी image पहले से कहीं और hosted है। `image` यदि आपकी image पहले से कहीं और hosted है, तो query string में parameter के रूप में

#### Path Parameters

| Name        | प्रकार | विवरण                                                                                                    |
| ----------- | ------ | -------------------------------------------------------------------------------------------------------- |
| datasetSlug | string | डेटासेट नाम का URL-सुरक्षित संस्करण। आप इसे मुख्य प्रोजेक्ट दृश्य पर URL देखकर वेब UI में ढूँढ सकते हैं। |
|             | string | आपके डेटासेट के संस्करण की पहचान करने वाला संस्करण नंबर।                                                 |

#### क्वेरी पैरामीटर्स

| Name     | प्रकार | विवरण                                                                    |
| -------- | ------ | ------------------------------------------------------------------------ |
| api\_key | string | आपकी API key (जो आपके workspace API settings page से प्राप्त की जाती है) |

{% tabs %}
{% tab title="200: OK " %}

```json
{
   "predictions":{
      "bird":{
         "confidence":0.5282308459281921
      },
      "cat":{
         "confidence":0.5069406032562256
      },
      "dog":{
         "confidence":0.49514248967170715
      }
   },
   "predicted_classes":[
      "bird",
      "cat"
   ]
}
```

{% endtab %}

{% tab title="403: Forbidden " %}

```json
{
   "message":"Forbidden"
}j
```

{% endtab %}
{% endtabs %}
