डिप्लॉय सर्वरलेस होस्टेड एपीआई ऑब्जेक्ट डिटेक्शन रोबोफ्लो पर होस्ट किए गए अपने ऑब्जेक्ट डिटेक्शन मॉडल्स पर इनफेरेंस चलाएँ।
Roboflow होस्टेड 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" )
लिनक्स या मैकओएस
एक स्थानीय फ़ाइल के लिए 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"
विंडोज़
आपको इंस्टॉल करना होगा विंडोज़ के लिए curl और विंडोज़ के लिए GNU का base64 टूल । इसे करने का सबसे आसान तरीका है विंडोज़ के लिए 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);
});
वेब
हमारे पास डिवाइस पर रीयलटाइम इंफरेंस उपलब्ध है roboflow.js
; देखें यहाँ डाक्यूमेंटेशन .
स्विफ्ट
स्थानीय छवि पर इंफर करना
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, मॉडल और मॉडल वर्शन के साथ इंफरेंस सर्वर अनुरोध इनिशियलाइज़ करें
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 स्निपेट का अनुरोध करने के लिए यहाँ क्लिक करें।
कोटलिन
स्थानीय छवि पर इंफर करना
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 कुंजी
val MODEL_ENDPOINT = "dataset/v" // मॉडल एंडपॉइंट सेट करें (डेटासेट 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 कुंजी
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()
जावा
स्थानीय छवि पर इंफर करना
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 कुंजी
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 कुंजी
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 कुंजी
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 कुंजी
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 कुंजी सेट करें
$model_endpoint = "dataset/v"; // मॉडल एंडपॉइंट सेट करें (डेटासेट 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 कुंजी सेट करें
$model_endpoint = "dataset/v"; // मॉडल एंडपॉइंट सेट करें (डेटासेट 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 कुंजी
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 कुंजी
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 कुंजी
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 कुंजी
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 संदर्भ
URL
पोस्ट
https://detect.roboflow.com/:projectId/:versionNumber
डेटासेट नाम का url-सुरक्षित संस्करण। आप इसे वेब UI में मुख्य प्रोजेक्ट दृश्य पर URL देखकर या अपने मॉडल को ट्रेन करने के बाद अपने डेटासेट संस्करण के ट्रेन परिणाम अनुभाग में "Get curl command" बटन पर क्लिक करके पा सकते हैं।
संस्करण संख्या जो आपके डेटासेट के संस्करण की पहचान करती है
Hosted Inference API को REST अनुरोध के माध्यम से छवि भेजने के दो तरीके हैं:
संलग्न करें base64
एन्कोडेड छवि को पोस्ट
अनुरोध बॉडी
छवि फ़ाइल का URL भेजें इमेज
URL क्वेरी
उदा: https://detect.roboflow.com/:datasetSlug/:versionNumber?image=https://imageurl.com
क्वेरी पैरामीटर
जोड़ने के लिए छवि का URL। इसका उपयोग करें यदि आपकी छवि कहीं और होस्ट की गई है। (आवश्यक जब आप अनुरोध बॉडी में base64 एन्कोडेड छवि पोस्ट नहीं करते हैं।)
नोट: URL-एन्कोड करना न भूलें।
प्रेडिक्शन को केवल कुछ निश्चित क्लासेस तक सीमित करें। इसे कॉमा से अलग स्ट्रिंग के रूप में दें।
उदाहरण: dog,cat
डिफ़ॉल्ट: मौजूद नहीं (सभी क्लासेस दिखाएँ)
अधिकतम प्रतिशत (0-100 के पैमाने पर) जो एक ही क्लास की बाउंडिंग बॉक्स प्रेडिक्शन को एक बॉक्स में मिलाने से पहले ओवरलैप करने की अनुमति है।
डिफ़ॉल्ट: 30
वापसी की गई प्रेडिक्शन के लिए एक थ्रेशोल्ड 0-100 के पैमाने पर। कम संख्या अधिक प्रेडिक्शन लौटाएगी। अधिक संख्या कम लेकिन अधिक निश्चितता वाली प्रेडिक्शन लौटाएगी।
डिफ़ॉल्ट: 40
बाउंडिंग बॉक्स की चौड़ाई (पिक्सल में) जो प्रेडिक्शन के चारों ओर दिखाई जाती है (केवल तभी प्रभावी जब फॉर्मेट
है इमेज
).
डिफ़ॉल्ट: 1
क्या प्रेडिक्शन पर टेक्स्ट लेबल दिखाना है या नहीं (केवल तभी प्रभावी जब फॉर्मेट
है इमेज
).
डिफ़ॉल्ट: false
विकल्प:
json: JSON प्रेडिक्शन की एक ऐरे लौटाता है। (प्रतिक्रिया प्रारूप टैब देखें)।
image: एनोटेटेड प्रेडिक्शन के साथ एक छवि लौटाता है एक बाइनरी ब्लॉब के रूप में जिसमें Content-Type
का image/jpeg
.
डिफ़ॉल्ट : json
आपकी API कुंजी (आपके कार्यक्षेत्र API सेटिंग्स पेज से प्राप्त)
अनुरोध बॉडी
एक base64 एन्कोडेड छवि। (आवश्यक जब आप क्वेरी पैरामीटर में छवि URL पास नहीं करते हैं।)
सामग्री प्रकार होना चाहिए application/x-www-form-urlencoded
एक स्ट्रिंग बॉडी के साथ।
प्रतिक्रिया प्रारूप
होस्टेड API इंफरेंस एंडपॉइंट, साथ ही हमारे अधिकांश SDKs, लौटाते हैं JSON
ऑब्जेक्ट जिसमें प्रेडिक्शन की एक ऐरे होती है। प्रत्येक प्रेडिक्शन में निम्नलिखित गुण होते हैं:
x
= डिटेक्टेड ऑब्जेक्ट का क्षैतिज केंद्र बिंदु
y
= डिटेक्टेड ऑब्जेक्ट का ऊर्ध्वाधर केंद्र बिंदु
चौड़ाई
= बाउंडिंग बॉक्स की चौड़ाई
ऊंचाई
= बाउंडिंग बॉक्स की ऊंचाई
क्लास
= डिटेक्टेड ऑब्जेक्ट का क्लास लेबल
कॉन्फिडेंस
= मॉडल का आत्मविश्वास कि डिटेक्टेड ऑब्जेक्ट के पास सही लेबल और स्थिति निर्देशांक हैं
यहाँ REST API से एक उदाहरण प्रतिक्रिया ऑब्जेक्ट है:
Copy {
"predictions": [
{
"x": 189.5,
"y": 100,
"width": 163,
"height": 186,
"class": "helmet",
"confidence": 0.544
}
],
"image": {
"width": 2048,
"height": 1371
}
}
यह इमेज
गुण में उस छवि की ऊंचाई और चौड़ाई होती है जिसे इंफरेंस के लिए भेजा गया था। आपको बाउंडिंग बॉक्स गणना के लिए इन मानों का उपयोग करने की आवश्यकता हो सकती है।
Inference API JSON आउटपुट से बॉक्स बनाना
बाउंडिंग बॉक्स रेंडर करने के लिए फ्रेमवर्क और पैकेज पोजिशनल फॉर्मेट्स में भिन्न हो सकते हैं। प्रतिक्रिया JSON
ऑब्जेक्ट के गुणों के अनुसार, एक बाउंडिंग बॉक्स हमेशा निम्नलिखित नियमों के कुछ संयोजन का उपयोग करके बनाया जा सकता है:
केंद्र बिंदु हमेशा होगा (x
,y
)
कोने के बिंदु (x1, y1)
और (x2, y2)
इनका पता लगाया जा सकता है:
कोने के बिंदु का तरीका एक सामान्य पैटर्न है और ऐसी लाइब्रेरीज़ में देखा जाता है जैसे Pillow
जब बनाते हैं बॉक्स
ऑब्जेक्ट जो बाउंडिंग बॉक्स को एक छवि
.
पर रेंडर करता है। जब आप predictions
!
Copy # Pillow लाइब्रेरी से उदाहरण बॉक्स ऑब्जेक्ट
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