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")

API Reference

URL

POST https://serverless.roboflow.com/:projectId/:versionNumber

Name
Type
Description

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

circle-info

देखें कि अपना project ID और version number कैसे प्राप्त करें यहाँarrow-up-right.

REST request के माध्यम से Serverless Hosted API पर image भेजने के दो तरीके हैं:

  • एक base64 encoded image को POST request body

  • के साथ एक image file का URL भेजें image URL query

    • उदाहरण: https://serverless.roboflow.com/:datasetSlug/:versionNumber?image=https://imageurl.com

Query Parameters

Name
Type
Description

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

Type
Description

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 point

  • y = detected object का vertical center point

  • width = bounding box की width

  • height = bounding box की height

  • class = detected object का class label

  • confidence = 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?