Copy
डिप्लॉय सर्वरलेस होस्टेड एपीआई ऑब्जेक्ट डिटेक्शन रोबोफ्लो पर होस्ट किए गए अपने ऑब्जेक्ट डिटेक्शन मॉडल्स पर इनफेरेंस चलाएँ।
Roboflow Hosted API का उपयोग करके ऑब्जेक्ट डिटेक्शन इंफरेंस चलाने के कई तरीके हैं। आप हमारे विभिन्न SDKs में से किसी एक का उपयोग कर सकते हैं, या हमारे होस्टेड एंडपॉइंट पर REST अनुरोध भेज सकते हैं।
डिपेंडेंसी इंस्टॉल करने के लिए, pip install inference-sdk
.
Copy # 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
:
Copy base64 YOUR_IMAGE.jpg | curl -d @- \
"https://detect.roboflow.com/your-model/42?api_key=YOUR_KEY"
वेब पर कहीं और होस्ट की गई इमेज पर उसके URL के माध्यम से इंफर करना (ना भूलें कि URL को एन्कोड करें ):
Copy 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 टूल । इसे करने का सबसे आसान तरीका है Windows के लिए git इंस्टॉलर जो साथ में curl
और base64
कमांड लाइन टूल्स भी देता है जब आप इंस्टॉलेशन के दौरान "Use Git and optional Unix tools from the Command Prompt" चुनते हैं।
फिर आप ऊपर दिए गए वही कमांड्स इस्तेमाल कर सकते हैं।
Node.js
हम उपयोग कर रहे हैं axios POST अनुरोध करने के लिए इस उदाहरण में, इसलिए पहले चलाएं npm install axios
डिपेंडेंसी इंस्टॉल करने के लिए।
लोकल इमेज पर इंफर करना
Copy 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 के माध्यम से इंफर करना
Copy 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
लोकल इमेज पर इंफर करना
Copy 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, Model, और Model Version के साथ Inference Server Request इनिशियलाइज़ करें
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
Objective-C स्निपेट के लिए यहाँ क्लिक करें।
Kotlin
लोकल इमेज पर इंफर करना
Copy 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)
// Base 64 एन्कोड
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" // मॉडल एंडपॉइंट सेट करें (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 के माध्यम से इंफर करना
Copy 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" // मॉडल एंडपॉइंट सेट करें
// अपलोड 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
लोकल इमेज पर इंफर करना
Copy 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);
// Base 64 एन्कोड
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"; // मॉडल एंडपॉइंट
// 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 के माध्यम से इंफर करना
Copy 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"; // मॉडल एंडपॉइंट
// अपलोड 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
Copy source "https://rubygems.org"
gem "httparty", "~> 0.18.1"
gem "base64", "~> 0.1.0"
gem "cgi", "~> 0.2.1"
Gemfile.lock
Copy 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
लोकल इमेज पर इंफर करना
Copy require 'base64'
require 'httparty'
encoded = Base64.encode64(File.open("YOUR_IMAGE.jpg", "rb").read)
model_endpoint = "dataset/v" # मॉडल एंडपॉइंट सेट करें
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 के माध्यम से इंफर करना
Copy require 'httparty'
require 'cgi'
model_endpoint = "dataset/v" # मॉडल एंडपॉइंट सेट करें
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
लोकल इमेज पर इंफर करना
Copy <?php
// इमेज को Base 64 में एन्कोड करें
$data = base64_encode(file_get_contents("YOUR_IMAGE.jpg"));
$api_key = ""; // API Key सेट करें
$model_endpoint = "dataset/v"; // मॉडल एंडपॉइंट सेट करें (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 के माध्यम से इंफर करना
Copy <?php
$api_key = ""; // API Key सेट करें
$model_endpoint = "dataset/v"; // मॉडल एंडपॉइंट सेट करें (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;
?>
लोकल इमेज पर इंफर करना
Copy package main
import (
"bufio"
"encoding/base64"
"fmt"
"io/ioutil"
"os"
"net/http"
"strings"
)
func main() {
api_key := "" // आपका API Key
model_endpoint := "dataset/v" // मॉडल एंडपॉइंट सेट करें
// डिस्क पर फाइल खोलें।
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 के माध्यम से इंफर करना
Copy package main
import (
"fmt"
"net/http"
"net/url"
"io/ioutil"
)
func main() {
api_key := "" // आपका API Key
model_endpoint := "dataset/v" // मॉडल एंडपॉइंट सेट करें
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))
}
लोकल इमेज पर इंफर करना
Copy 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"; // मॉडल एंडपॉइंट सेट करें
// 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 के माध्यम से इंफर करना
Copy 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"; // मॉडल एंडपॉइंट सेट करें
// 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);
}
}
}
API Reference
URL
POST
https://detect.roboflow.com/:projectId/:versionNumber
डेटासेट नाम का url-safe वर्शन। आप इसे वेब UI में मुख्य प्रोजेक्ट व्यू पर URL देखकर या ट्रेनिंग के बाद अपने डेटासेट वर्शन के ट्रेन रिजल्ट्स सेक्शन में "Get curl command" बटन पर क्लिक करके पा सकते हैं।
आपके डेटासेट के वर्शन की पहचान करने वाला वर्शन नंबर
Hosted Inference API को REST अनुरोध के माध्यम से इमेज भेजने के दो तरीके हैं:
एक base64
एन्कोडेड इमेज को POST
अनुरोध बॉडी में जोड़ें
इमेज फाइल का URL भेजें इमेज
URL query
उदाहरण: https://detect.roboflow.com/:datasetSlug/:versionNumber?image=https://imageurl.com
क्वेरी पैरामीटर
जोड़ने के लिए इमेज का URL। उपयोग करें यदि आपकी इमेज कहीं और होस्ट की गई है। (आवश्यक जब आप अनुरोध बॉडी में base64 एन्कोडेड इमेज POST नहीं करते हैं।)
नोट: ना भूलें कि इसे URL-encode करें।
प्रेडिक्शन को केवल कुछ निश्चित classes तक सीमित करें। इसे कॉमा सेपरेटेड स्ट्रिंग के रूप में दें।
उदाहरण: dog,cat
Default: not present (सभी classes दिखाएँ)
अधिकतम प्रतिशत (0-100 के पैमाने पर) जितना bounding box prediction एक ही class के allowed हैं ओवरलैप करने के लिए, इससे पहले कि उन्हें एक बॉक्स में मिला दिया जाए।
Default: 30
रिटर्न किए गए प्रेडिक्शन के लिए थ्रेशहोल्ड (0-100 के पैमाने पर)। कम नंबर अधिक prediction लौटाएगा। अधिक नंबर कम लेकिन अधिक निश्चितता वाले prediction लौटाएगा।
Default: 40
prediction के चारों ओर दिखाए गए bounding box की चौड़ाई (पिक्सल में) (केवल तभी प्रभाव डालता है जब format
है इमेज
).
Default: 1
prediction पर टेक्स्ट लेबल दिखाना है या नहीं (केवल तभी प्रभाव डालता है जब format
है इमेज
).
Default: false
विकल्प:
json: JSON प्रेडिक्शन की एक array लौटाता है। (रिस्पॉन्स फॉर्मेट टैब देखें)।
image: एनोटेटेड प्रेडिक्शन के साथ एक इमेज लौटाता है, एक बाइनरी blob के रूप में जिसमें Content-Type
का image/jpeg
.
Default : json
आपका API key (आपके workspace API settings पेज से प्राप्त)
रिक्वेस्ट बॉडी
एक base64 एन्कोडेड इमेज। (आवश्यक जब आप query parameters में इमेज URL पास नहीं करते हैं)।
content type होना चाहिए application/x-www-form-urlencoded
स्ट्रिंग बॉडी के साथ।
hosted API inference endpoint, साथ ही हमारे अधिकांश SDKs, लौटाते हैं JSON
ऑब्जेक्ट जिसमें prediction की array होती है। हर prediction में निम्नलिखित properties होती हैं:
x
= डिटेक्टेड ऑब्जेक्ट का क्षैतिज केंद्र बिंदु
y
= डिटेक्टेड ऑब्जेक्ट का ऊर्ध्वाधर केंद्र बिंदु
width
= bounding box की चौड़ाई
height
= bounding box की ऊँचाई
class
= डिटेक्टेड ऑब्जेक्ट का class लेबल
confidence
= मॉडल का confidence कि डिटेक्टेड ऑब्जेक्ट का लेबल और पोजिशन सही है
यहाँ REST API से एक उदाहरण response object है:
Copy {
"predictions": [
{
"x": 189.5,
"y": 100,
"width": 163,
"height": 186,
"class": "helmet",
"confidence": 0.544
}
],
"image": {
"width": 2048,
"height": 1371
}
}
The इमेज
attribute में उस इमेज की ऊँचाई और चौड़ाई होती है जिसे inference के लिए भेजा गया था। आपको bounding box कैलकुलेशन के लिए इन मानों का उपयोग करना पड़ सकता है।
Inference API JSON आउटपुट से बॉक्स बनाना
bounding box रेंडर करने के लिए frameworks और packages में पोजिशनल फॉर्मेट अलग हो सकते हैं। response JSON
object की properties के अनुसार, bounding box हमेशा निम्नलिखित नियमों के कुछ संयोजन से बनाया जा सकता है:
center point हमेशा होगा (x
,y
)
corner points (x1, y1)
और (x2, y2)
इनका पता लगाया जा सकता है:
corner points का तरीका एक सामान्य पैटर्न है और इसे ऐसी लाइब्रेरीज़ में देखा जाता है जैसे Pillow
जब आप बना रहे हों box
object ताकि bounding boxes को एक Image
.
के भीतर रेंडर किया जा सके। सभी detections के लिए iteration करना न भूलें जब आप काम कर रहे हों predictions
!
Copy # Pillow लाइब्रेरी से उदाहरण 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)
Last updated 6 months ago