Object Detection
Roboflow पर hosted आपके object detection models पर inference चलाएं।
Roboflow Hosted API का उपयोग करके object detection inference चलाने के कई तरीके हैं। आप हमारे विभिन्न SDKs में से किसी एक का उपयोग कर सकते हैं, या हमारे hosted endpoint पर REST request भेज सकते हैं।
Dependencies install करने के लिए, pip install inference-sdk.
# 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")Linux या MacOS
नाम की एक local file के लिए JSON predictions प्राप्त करना YOUR_IMAGE.jpg:
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 करना न भूलें):
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 और Windows के लिए GNU का base64 tool. ऐसा करने का सबसे आसान तरीका है Windows installer के लिए git जिसमें curl और base64 command line tools भी शामिल होते हैं जब आप installation के दौरान "Use Git and optional Unix tools from the Command Prompt" चुनते हैं।
फिर आप ऊपर वाले समान commands का उपयोग कर सकते हैं।
Node.js
हम उपयोग कर रहे हैं axios इस उदाहरण में POST request करने के लिए, इसलिए पहले चलाएँ npm install axios dependency install करने के लिए।
Local Image पर inference करना
URL के माध्यम से कहीं और host की गई image पर inference करना
Web
हमारे पास realtime on-device inference उपलब्ध है roboflow.jsके माध्यम से; देखें दस्तावेज़ यहाँ.
Swift
Local Image पर inference करना
Objective C
Kotlin
Local Image पर inference करना
URL के माध्यम से कहीं और host की गई image पर inference करना
Java
Local Image पर inference करना
URL के माध्यम से कहीं और host की गई image पर inference करना
Gemfile
Gemfile.lock
Local Image पर inference करना
URL के माध्यम से कहीं और host की गई image पर inference करना
Local Image पर inference करना
URL के माध्यम से कहीं और host की गई image पर inference करना
Local Image पर inference करना
URL के माध्यम से कहीं और host की गई image पर inference करना
Local Image पर inference करना
URL के माध्यम से कहीं और host की गई image पर inference करना
हमारे AI-powered chatbot Lenny से पूछकर अपने लिए code sample बनवाने की कोशिश करें!
API Reference
URL
POST https://serverless.roboflow.com/:projectId/:versionNumber
projectId
string
dataset नाम का URL-safe version। आप इसे web UI में मुख्य project view के URL को देखकर, या model training के बाद अपने dataset version के train results section में "Get curl command" बटन पर क्लिक करके पा सकते हैं।
version
number
अपने dataset के version की पहचान करने वाला version number
देखें कि अपना project ID और version number कैसे प्राप्त करें यहाँ.
REST request के माध्यम से Serverless Hosted API पर image भेजने के दो तरीके हैं:
एक
base64encoded image कोPOSTrequest bodyके साथ एक image file का URL भेजें
imageURL queryउदाहरण:
https://serverless.roboflow.com/:datasetSlug/:versionNumber?image=https://imageurl.com
Query Parameters
image
string
जो image जोड़नी है उसका URL। उपयोग करें यदि आपकी image कहीं और hosted है। (जब आप request body में base64 encoded image POST नहीं करते हैं, तब आवश्यक।) नोट: इसे URL-encode करना न भूलें।
classes
string
predictions को केवल कुछ निश्चित classes तक सीमित करें। comma-separated string के रूप में दें। उदाहरण: dog,cat Default: मौजूद नहीं (सभी classes दिखाएँ)
overlap
number
अधिकतम प्रतिशत (0-100 के पैमाने पर) जिस तक समान class के bounding box predictions को एक single box में combine करने से पहले overlap करने की अनुमति है।
Default: 30
इस parameter का RF-DETR models पर कोई प्रभाव नहीं पड़ता।
confidence
number
0-100 के पैमाने पर returned predictions के लिए एक threshold। कम संख्या अधिक predictions लौटाएगी। अधिक संख्या कम high-certainty predictions लौटाएगी।
Default: 40
stroke
number
predictions के चारों ओर प्रदर्शित bounding box की चौड़ाई (pixels में) (केवल तब प्रभावी होती है जब format है image).
Default: 1
लेबल
बूलियन
क्या predictions पर text labels दिखाने हैं या नहीं (सिर्फ तब प्रभावी होता है जब format है image).
Default: false
format
string
विकल्प:
json: JSON predictions की एक array लौटाता है। (response format टैब देखें)।
image: annotated predictions वाली एक image को binary blob के रूप में लौटाता है, एक
Content-Typeकेimage/jpeg.
डिफ़ॉल्ट: json
api_key
string
आपकी API key (जो आपके workspace API settings page से प्राप्त होती है)
Request Body
string
एक base64 encoded image। (अनिवार्य जब आप query parameters में image URL नहीं देते)।
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 pointy= detected object का vertical center pointwidth= bounding box की widthheight= bounding box की heightclass= detected object का class labelconfidence= model का confidence कि detected object का label और position coordinates सही हैं
REST API से एक उदाहरण response object यहाँ है:
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!
Last updated
Was this helpful?