Object Detection
Roboflow पर होस्ट किए गए अपने object detection मॉडलों पर inference चलाएँ।
Roboflow Hosted API का उपयोग करके वस्तु पहचान (object detection) इनफरेंस चलाने के कई तरीके हैं। आप हमारे विभिन्न SDKs में से किसी एक का उपयोग कर सकते हैं, या हमारे होस्ट किए गए endpoint पर एक REST अनुरोध भेज सकते हैं।
निर्भरता स्थापित करने के लिए, pip install inference-sdk.
# inference-sdk आयात करें
from inference_sdk import InferenceHTTPClient
CLIENT = InferenceHTTPClient(
api_url="https://detect.roboflow.com",
api_key="API_KEY"
)
result = CLIENT.infer(your_image.jpg, model_id="football-players-detection-3zvbc/12")Linux या MacOS
स्थानीय फ़ाइल के लिए JSON भविष्यवाणियाँ प्राप्त करना जिसका नाम है YOUR_IMAGE.jpg:
base64 YOUR_IMAGE.jpg | curl -d @- \
"https://detect.roboflow.com/your-model/42?api_key=YOUR_KEY"वेब पर कहीं और होस्ट की गई छवि के URL के माध्यम से इनफर करने के लिए (भूलें नहीं कि इसे URL encode करें):
curl -X POST "https://detect.roboflow.com/your-model/42?\
api_key=YOUR_KEY&\
image=https%3A%2F%2Fi.imgur.com%2FPEEvqPN.png"Windows
आपको स्थापित करने की आवश्यकता होगी Windows के लिए curl और Windows के लिए GNU का base64 टूल. इसे करने का सबसे आसान तरीका है कि आप git for Windows इंस्टॉलर जिसमें यह भी शामिल है curl और base64 कमांड लाइन टूल जब आप इंस्टॉल के दौरान "Use Git and optional Unix tools from the Command Prompt" का चयन करते हैं।
फिर आप ऊपर दिए गए समान कमांड्स का उपयोग कर सकते हैं।
Node.js
हम उपयोग कर रहे हैं axios इस उदाहरण में POST अनुरोध करने के लिए, इसलिए पहले चलाएँ npm install axios निर्भरता स्थापित करने के लिए।
स्थानीय छवि पर इनफर करना
const axios = require("axios");
const fs = require("fs");
const image = fs.readFileSync("YOUR_IMAGE.jpg", {
encoding: "base64"
});
axios({
method: "POST",
url: "https://detect.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 के माध्यम से) पर इनफर करना
const axios = require("axios");
axios({
method: "POST",
url: "https://detect.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
हमारे पास रीयलटाइम ऑन-डिवाइस इनफरेंस उपलब्ध है द्वारा roboflow.js; देखें दस्तावेज़ यहाँ.
Swift
स्थानीय छवि पर इनफर करना
import UIKit
// इमेज लोड करें और इसे Base64 में बदलें
let image = UIImage(named: "your-image-path") // अपलोड करने के लिए छवि का पथ उदाहरण: image.jpg
let imageData = image?.jpegData(compressionQuality: 1)
let fileContent = imageData?.base64EncodedString()
let postData = fileContent!.data(using: .utf8)
// API_KEY, मॉडल, और मॉडल संस्करण के साथ इनफरेंस सर्वर अनुरोध प्रारम्भ करें
var request = URLRequest(url: URL(string: "https://detect.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
// पोस्ट अनुरोध निष्पादित करें
URLSession.shared.dataTask(with: request, completionHandler: { data, response, error in
// उत्तर को स्ट्रिंग में पार्स करें
guard let data = data else {
print(String(describing: error))
return
}
// प्रतिक्रिया स्ट्रिंग को डिक्शनरी में बदलें
do {
let dict = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
} catch {
print(error.localizedDescription)
}
// स्ट्रिंग प्रतिक्रिया प्रिंट करें
print(String(data: data, encoding: .utf8)!)
}).resume()Objective C
Kotlin
स्थानीय छवि पर इनफर करना
import java.io.*
import java.net.HttpURLConnection
import java.net.URL
import java.nio.charset.StandardCharsets
import java.util.*
fun main() {
// इमेज पथ प्राप्त करें
val filePath = System.getProperty("user.dir") + System.getProperty("file.separator") + "YOUR_IMAGE.jpg"
val file = File(filePath)
// Base64 एन्कोड करें
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" // मॉडल endpoint सेट करें (Dataset URL में मिलता है)
// URL बनाएं
val uploadURL ="https://detect.roboflow.com/" + MODEL_ENDPOINT + "?api_key=" + API_KEY + "&name=YOUR_IMAGE.jpg";
// Http अनुरोध
var connection: HttpURLConnection? = null
try {
// URL के लिए कनेक्शन कॉन्फ़िगर करें
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
// अनुरोध भेजें
val wr = DataOutputStream(
connection.outputStream)
wr.writeBytes(encodedFile)
wr.close()
// प्रतिक्रिया प्राप्त करें
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 के माध्यम से) पर इनफर करना
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" // छवि URL बदलें
val API_KEY = "" // आपका API Key
val MODEL_ENDPOINT = "dataset/v" // मॉडल endpoint सेट करें
// अपलोड URL
val uploadURL = "https://detect.roboflow.com/" + MODEL_ENDPOINT + "?api_key=" + API_KEY + "&image=" + URLEncoder.encode(imageURL, "utf-8");
// Http अनुरोध
var connection: HttpURLConnection? = null
try {
// URL के लिए कनेक्शन कॉन्फ़िगर करें
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
// अनुरोध भेजें
val wr = DataOutputStream(connection.outputStream)
wr.writeBytes(uploadURL)
wr.close()
// प्रतिक्रिया प्राप्त करें
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
स्थानीय छवि पर इनफर करना
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 {
// इमेज पथ प्राप्त करें
String filePath = System.getProperty("user.dir") + System.getProperty("file.separator") + "YOUR_IMAGE.jpg";
File file = new File(filePath);
// Base64 एन्कोड करें
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"; // मॉडल endpoint
// URL बनाएं
String uploadURL = "https://detect.roboflow.com/" + MODEL_ENDPOINT + "?api_key=" + API_KEY
+ "&name=YOUR_IMAGE.jpg";
// Http अनुरोध
HttpURLConnection connection = null;
try {
// URL के लिए कनेक्शन कॉन्फ़िगर करें
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);
// अनुरोध भेजें
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.writeBytes(encodedFile);
wr.close();
// प्रतिक्रिया प्राप्त करें
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 के माध्यम से) पर इनफर करना
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"; // छवि URL बदलें
String API_KEY = ""; // आपका API Key
String MODEL_ENDPOINT = "dataset/v"; // मॉडल endpoint
// अपलोड URL
String uploadURL = "https://detect.roboflow.com/" + MODEL_ENDPOINT + "?api_key=" + API_KEY + "&image="
+ URLEncoder.encode(imageURL, StandardCharsets.UTF_8);
// Http अनुरोध
HttpURLConnection connection = null;
try {
// URL के लिए कनेक्शन कॉन्फ़िगर करें
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);
// अनुरोध भेजें
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.writeBytes(uploadURL);
wr.close();
// प्रतिक्रिया प्राप्त करें
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();
}
}
}
}Gemfile
source "https://rubygems.org"
gem "httparty", "~> 0.18.1"
gem "base64", "~> 0.1.0"
gem "cgi", "~> 0.2.1"Gemfile.lock
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स्थानीय छवि पर इनफर करना
require 'base64'
require 'httparty'
encoded = Base64.encode64(File.open("YOUR_IMAGE.jpg", "rb").read)
model_endpoint = "dataset/v" # मॉडल endpoint सेट करें
api_key = "" # आपका API KEY यहाँ
params = "?api_key=" + api_key
+ "&name=YOUR_IMAGE.jpg"
response = HTTParty.post(
"https://detect.roboflow.com/" + model_endpoint + params,
body: encoded,
headers: {
'Content-Type' => 'application/x-www-form-urlencoded',
'charset' => 'utf-8'
})
puts response
कहीं और होस्ट की गई छवि (URL के माध्यम से) पर इनफर करना
require 'httparty'
require 'cgi'
model_endpoint = "dataset/v" # मॉडल endpoint सेट करें
api_key = "" # आपका API KEY यहाँ
img_url = "https://i.imgur.com/PEEvqPN.png" # URL बनाएं
img_url = CGI::escape(img_url)
params = "?api_key=" + api_key + "&image=" + img_url
response = HTTParty.post(
"https://detect.roboflow.com/" + model_endpoint + params,
headers: {
'Content-Type' => 'application/x-www-form-urlencoded',
'charset' => 'utf-8'
})
puts responseस्थानीय छवि पर इनफर करना
<?php
// इमेज को Base64 में एन्कोड करें
$data = base64_encode(file_get_contents("YOUR_IMAGE.jpg"));
$api_key = ""; // API Key सेट करें
$model_endpoint = "dataset/v"; // मॉडल endpoint सेट करें (Dataset URL में मिलता है)
// Http अनुरोध के लिए URL
$url = "https://detect.roboflow.com/" . $model_endpoint
. "?api_key=" . $api_key
. "&name=YOUR_IMAGE.jpg";
// सेटअप + Http अनुरोध भेजें
$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 के माध्यम से) पर इनफर करना
<?php
$api_key = ""; // API Key सेट करें
$model_endpoint = "dataset/v"; // मॉडल endpoint सेट करें (Dataset URL में मिलता है)
$img_url = "https://i.imgur.com/PEEvqPN.png";
// Http अनुरोध के लिए URL
$url = "https://detect.roboflow.com/" . $model_endpoint
. "?api_key=" . $api_key
. "&image=" . urlencode($img_url);
// सेटअप + Http अनुरोध भेजें
$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;
?>स्थानीय छवि पर इनफर करना
package main
import (
"bufio"
"encoding/base64"
"fmt"
"io/ioutil"
"os"
"net/http"
"strings"
)
func main() {
api_key := "" // आपका API Key
model_endpoint := "dataset/v" // मॉडल endpoint सेट करें
// डिस्क पर फाइल खोलें।
f, _ := os.Open("YOUR_IMAGE.jpg")
// पूरी JPG को बाइट स्लाइस में पढ़ें।
reader := bufio.NewReader(f)
content, _ := ioutil.ReadAll(reader)
// Base64 में एन्कोड करें।
data := base64.StdEncoding.EncodeToString(content)
uploadURL := "https://detect.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 के माध्यम से) पर इनफर करना
package main
import (
"fmt"
"net/http"
"net/url"
"io/ioutil"
)
func main() {
api_key := "" // आपका API Key
model_endpoint := "dataset/v" // मॉडल endpoint सेट करें
img_url := "https://i.ibb.co/jzr27x0/YOUR-IMAGE.jpg"
uploadURL := "https://detect.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))
}स्थानीय छवि पर इनफर करना
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"; // मॉडल endpoint सेट करें
// URL बनाएं
string uploadURL =
"https://detect.roboflow.com/" + MODEL_ENDPOINT + "?api_key=" + API_KEY
+ "&name=YOUR_IMAGE.jpg";
// सर्विस अनुरोध कॉन्फ़िग
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
// अनुरोध कॉन्फ़िगर करें
WebRequest request = WebRequest.Create(uploadURL);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
// डेटा लिखें
using (Stream stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
// प्रतिक्रिया प्राप्त करें
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 के माध्यम से) पर इनफर करना
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"; // मॉडल endpoint सेट करें
// URL बनाएं
string uploadURL =
"https://detect.roboflow.com/" + MODEL_ENDPOINT
+ "?api_key=" + API_KEY
+ "&image=" + HttpUtility.UrlEncode(imageURL);
// सर्विस प्वाइंट कॉन्फ़िग
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
// Http अनुरोध कॉन्फ़िगर करें
WebRequest request = WebRequest.Create(uploadURL);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = 0;
// प्रतिक्रिया प्राप्त करें
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);
}
}
}inferencejs के साथ एज inference
URL
POST https://detect.roboflow.com/:projectId/:versionNumber
projectId
string
डेटासेट नाम का URL-सुरक्षित (url-safe) संस्करण। आप इसे वेब UI में मुख्य प्रोजेक्ट दृश्य पर URL देखकर पा सकते हैं या अपने मॉडल के प्रशिक्षण के बाद dataset version के train results सेक्शन में "Get curl command" बटन पर क्लिक करके भी देख सकते हैं।
version
number
आपके डेटासेट के संस्करण की पहचान करने वाला संस्करण संख्या
Hosted Inference API को REST अनुरोध के माध्यम से छवि भेजने के दो तरीके हैं:
एक संलग्न करें
base64एन्कोड की गई छवि कोPOSTअनुरोध बॉडीछवि फ़ाइल का URL भेजें उपयोग करते हुए
imageURL क्वेरीउदा:
https://detect.roboflow.com/:datasetSlug/:versionNumber?image=https://imageurl.com
क्वेरी पैरामीटर
image
string
जोड़ने के लिए छवि का URL। उपयोग करें यदि आपकी छवि कहीं और होस्ट की गई है। (जब आप अनुरोध बॉडी में base64 एन्कोडेड छवि POST नहीं करते हैं तो आवश्यक)। नोट: इसे URL-encode करना न भूलें।
classes
string
भविष्यवाणियों को केवल कुछ विशिष्ट क्लासेस तक सीमित करें। कॉमा-सेपरेटेड स्ट्रिंग के रूप में प्रदान करें। उदाहरण: dog,cat डिफ़ॉल्ट: मौजूद नहीं (सभी क्लास दिखाएँ)
overlap
number
एक ही क्लास की bounding box भविष्यवाणियों को एक ही बॉक्स में मिलाने से पहले उनकी अधिकतम ओवरलैप प्रतिशत (0-100 के पैमाने पर)।
डिफ़ॉल्ट: 30
confidence
number
0-100 के पैमाने पर लौटाई गई भविष्यवाणियों के लिए एक थ्रेशोल्ड। कम संख्या अधिक भविष्यवाणियाँ लौटाएगी। अधिक संख्या उच्च-निश्चितता वाली कम भविष्यवाणियाँ लौटाएगी।
डिफ़ॉल्ट: 40
stroke
number
भविष्यवाणियों के आसपास प्रदर्शित bounding box की चौड़ाई (पिक्सल में) (केवल तब प्रभावी जब format है image).
डिफ़ॉल्ट: 1
labels
boolean
क्या भविष्यवाणियों पर टेक्स्ट लेबल दिखाना है या नहीं (केवल तब प्रभावी जब format है image).
डिफ़ॉल्ट: false
format
string
विकल्प:
json: JSON भविष्यवाणियों की एक array लौटाता है। (レスपॉन्स फ़ॉर्मेट टैब देखें)।
image: एनोटेटेड भविष्यवाणियों के साथ एक छवि बाइनरी ब्लॉब के रूप में लौटाता है जिसमें
Content-Typeहैimage/jpeg.
डिफ़ॉल्ट: json
api_key
string
आपकी API key (आपके Workspace API settings पृष्ठ से प्राप्त)
रिक्वेस्ट बॉडी
string
एक base64 एन्कोडेड छवि। (जब आप query parameters में छवि URL पास नहीं करते हैं तो आवश्यक)।
सामग्री प्रकार होना चाहिए application/x-www-form-urlencoded एक string बॉडी के साथ।
प्रतिक्रिया फ़ॉर्मेट
होस्ट किया गया API inference endpoint, और हमारे अधिकांश SDKs, एक लौटाते हैं JSON एक ऑब्जेक्ट जिसमें predictions की एक array होती है। प्रत्येक prediction के निम्नलिखित गुण होते हैं:
x= पहचान किए गए ऑब्जेक्ट का क्षैतिज केंद्र बिंदुy= पहचान किए गए ऑब्जेक्ट का ऊर्ध्वाधर केंद्र बिंदुwidth= bounding box की चौड़ाईheight= bounding box की ऊँचाईclass= पहचान किए गए ऑब्जेक्ट का क्लास लेबलconfidence= मॉडल का भरोसा (confidence) कि पहचान किया गया ऑब्जेक्ट सही लेबल और स्थिति निर्देशांकों के साथ है
यहाँ REST API से एक उदाहरण प्रतिक्रिया ऑब्जेक्ट है:
{
"predictions": [
{
"x": 189.5,
"y": 100,
"width": 163,
"height": 186,
"class": "helmet",
"confidence": 0.544
}
],
"image": {
"width": 2048,
"height": 1371
}
}The image attribute उस छवि की ऊँचाई और चौड़ाई को दर्शाता है जो inference के लिए भेजी गई थी। bounding box की गणनाओं के लिए आपको इन मानों का उपयोग करना पड़ सकता है।
Inference API JSON आउटपुट से बॉक्स बनाना
bounding boxes को रेंडर करने के लिए frameworks और पैकेज positional फॉर्मैट में भिन्न हो सकते हैं। दिए गए प्रतिक्रिया JSON ऑब्जेक्ट के गुणों को देखते हुए, निम्नलिखित नियमों के किसी संयोजन का उपयोग करके हमेशा एक bounding box बनाया जा सकता है:
केंद्र बिंदु हमेशा होगा (
x,y)कोण बिंदु
(x1, y1)और(x2, y2)इनका पता लगाया जा सकता है:x1=x - (width/2)y1=y - (height/2)x2=x + (width/2)y2=y + (height/2)
कोण बिंदुओं का तरीका एक सामान्य पैटर्न है और लाइब्रेरीज़ में देखा जाता है जैसे Pillow जब बनाते हैं box ऑब्जेक्ट bounding boxes को एक के भीतर रेंडर करने के लिए Image.
जब काम कर रहे हों तो सभी मिलान (detections) के माध्यम से iterate करना न भूलें predictions!
# Pillow लाइब्रेरी से उदाहरण box ऑब्जेक्ट
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)Last updated
Was this helpful?