For the complete documentation index, see llms.txt. This page is also available as Markdown.

Serverless Cloud API

Roboflow cloud में GPU-accelerated auto-scaling infrastructure पर Workflows और Model Inference चलाएँ।

के बारे में

Roboflow पर तैनात मॉडल्स के लिए एक REST API उपलब्ध होती है, जिसके माध्यम से आप इमेजों पर इन्फ़रेंस चला सकते हैं। यह डिप्लॉयमेंट तरीका उन परिवेशों के लिए आदर्श है जहाँ आपके डिप्लॉयमेंट डिवाइस पर स्थायी इंटरनेट कनेक्शन होता है।

ऐप में, इस एंडपॉइंट को "Serverless Cloud API" कहा जाता है, या जहाँ जगह कम हो वहाँ "Cloud API" (उदा.: Workflow editor runtime picker)। एक समर्पित डिप्लॉयमेंट एंडपॉइंट (*.roboflow.cloud) को "Dedicated Cloud API" कहा जाता है, और पुराने v1 एंडपॉइंट को "Hosted API (Legacy)" कहा जाता है। ये लेबल पहले के "Serverless Hosted API" और "Serverless API V2" नामों की जगह लेते हैं।

आप Serverless Cloud API का उपयोग कर सकते हैं:

Inference सर्वर

हमारा Serverless Cloud API द्वारा संचालित है इन्फ़रेंस सर्वर. इसका मतलब है कि आप नीचे दिखाए अनुसार हमारे Serverless Cloud API और self-hosting विकल्प के बीच, और vice versa, आसानी से स्विच कर सकते हैं:

from inference_sdk import InferenceHTTPClient, InferenceConfiguration

CLIENT = InferenceHTTPClient(
    # api_url="http://localhost:9001" # स्व-होस्टेड Inference server
    api_url="https://serverless.roboflow.com", # हमारा Serverless Cloud API
    api_key="API_KEY" # अपने निजी मॉडल्स और डेटा तक पहुँचने के लिए वैकल्पिक
).configure(InferenceConfiguration(api_key_transport="header"))

result = CLIENT.infer("image.jpg", model_id="model-id/1")
print(result)

यह api_key_transport="header" सेटिंग कुंजी को केवल एक Authorization: Bearer हेडर, जिससे यह URLs और लॉग्स में नहीं जाता: सभी नए कोड के लिए अनुशंसित। Inference 1.5.0 से पुराने सर्वर हेडर नहीं पढ़ते; उपयोग करें api_key_transport="both" जबकि आप अभी भी एक को कॉल करते हैं। देखें API key transport.

सीमाएँ

हमारा Serverless Cloud API 20MB तक फ़ाइल अपलोड का समर्थन करता है। उच्च रिज़ॉल्यूशन वाली इमेजों के साथ आपको सीमाओं का सामना करना पड़ सकता है। यदि आपको कोई समस्या आती है, तो कृपया अपने एंटरप्राइज़ सपोर्ट संपर्क से संपर्क करें या फ़ोरम पर.

ऐसी स्थितियों में जहाँ अनुरोध बहुत बड़े हों, हम किसी भी संलग्न इमेज को छोटा करने की सलाह देते हैं। इससे आम तौर पर प्रदर्शन खराब नहीं होगा, क्योंकि इमेजें वैसे भी हमारे सर्वरों पर प्राप्त होने के बाद मॉडल आर्किटेक्चर द्वारा स्वीकार किए जाने वाले इनपुट आकार तक छोटा कर दी जाती हैं। हमारे कुछ SDKs, जैसे Python SDK, API को भेजे जाने से पहले ही इमेजों को मॉडल आर्किटेक्चर के इनपुट आकार तक स्वचालित रूप से छोटा कर देते हैं।


देखें Serverless Cloud API v1 विरासती API दस्तावेज़ीकरण के लिए।

HTTP API

REST API के साथ उपयोग करें

Serverless Cloud API में सभी मॉडल्स और वर्कफ़्लोज़ के लिए एक ही एंडपॉइंट है:

HTTP एंडपॉइंट्स

Legacy Infer From Request

post

Legacy inference endpoint for object detection, instance segmentation, and classification.

Args: background_tasks: (BackgroundTasks) pool of fastapi background tasks dataset_id (str): ID of a Roboflow dataset corresponding to the model to use for inference OR workspace ID version_id (str): ID of a Roboflow dataset version corresponding to the model to use for inference OR model ID api_key (Optional[str], default None): Roboflow API Key passed to the model during initialization for artifact retrieval. # Other parameters described in the function signature...

Returns: Union[InstanceSegmentationInferenceResponse, KeypointsDetectionInferenceRequest, ObjectDetectionInferenceResponse, ClassificationInferenceResponse, MultiLabelClassificationInferenceResponse, SemanticSegmentationInferenceResponse, Any]: The response containing the inference results.

Path parameters
dataset_idstringRequired

ID of a Roboflow dataset corresponding to the model to use for inference OR workspace ID

version_idstringRequired

ID of a Roboflow dataset version corresponding to the model to use for inference OR model ID

Query parameters
api_keystring · nullableOptional

Roboflow API Key that will be passed to the model during initialization for artifact retrieval

confidenceany ofOptional

The confidence threshold used to filter out predictions. Pass a float in [0, 1], or "best" to use F1-optimal thresholds from model evaluation, or "default" to use the model's built-in default.

Default: 0.4
numberOptional
or
string · enumOptionalPossible values:
keypoint_confidencenumberOptional

The confidence threshold used to filter out keypoints that are not visible based on model confidence

Default: 0
formatstringOptional

One of 'json' or 'image'. If 'json' prediction data is return as a JSON string. If 'image' prediction data is visualized and overlayed on the original input image.

Default: json
imagestring · nullableOptional

The publically accessible URL of an image to use for inference.

image_typestring · nullableOptional

One of base64 or numpy. Note, numpy input is not supported for Roboflow Hosted Inference.

Default: base64
class_filterstring · nullableOptional

Action recognition only: comma separated classes. The subset of a fine-tuned model's classes to report. A zero-shot model answers in its own words and ignores it.

labelsboolean · nullableOptional

If true, labels will be include in any inference visualization.

Default: false
mask_decode_modestring · nullableOptional

One of 'accurate' or 'fast'. If 'accurate' the mask will be decoded using the original image size. If 'fast' the mask will be decoded using the original mask size. 'accurate' is slower but more accurate.

Default: accurate
tradeoff_factornumber · nullableOptional

The amount to tradeoff between 0='fast' and 1='accurate'

Default: 0
max_detectionsintegerOptional

The maximum number of detections to return. This is used to limit the number of predictions returned by the model. The model may return more predictions than this number, but only the top max_detections predictions will be returned.

Default: 300
overlapnumberOptional

The IoU threhsold that must be met for a box pair to be considered duplicate during NMS

Default: 0.3
strokeintegerOptional

The stroke width used when visualizing predictions

Default: 1
disable_preproc_auto_orientboolean · nullableOptional

If true, disables automatic image orientation

Default: false
disable_preproc_contrastboolean · nullableOptional

If true, disables automatic contrast adjustment

Default: false
disable_preproc_grayscaleboolean · nullableOptional

If true, disables automatic grayscale conversion

Default: false
disable_preproc_static_cropboolean · nullableOptional

If true, disables automatic static crop

Default: false
disable_active_learningboolean · nullableOptional

If true, the predictions will be prevented from registration by Active Learning (if the functionality is enabled)

Default: false
active_learning_target_datasetstring · nullableOptional

Parameter to be used when Active Learning data registration should happen against different dataset than the one pointed by model_id

sourcestring · nullableOptional

The source of the inference request

Default: external
source_infostring · nullableOptional

The detailed source information of the inference request

Default: external
response_mask_formatstring · enum · nullableOptional

The format of the prediction mask - polygon (default) or rle - applicable for instance segmentation models.

Default: polygonPossible values:
Responses
200

Successful Response

application/json
or
or
or
or
or
or
or
anyOptional
post/{dataset_id}/{version_id}
POST /{dataset_id}/{version_id} HTTP/1.1
Accept: */*
{
  "visualization": "text",
  "inference_id": "text",
  "frame_id": 1,
  "time": 1,
  "image": [
    {
      "width": 1,
      "height": 1
    }
  ],
  "predictions": [
    {
      "x": 1,
      "y": 1,
      "width": 1,
      "height": 1,
      "confidence": 1,
      "class": "text",
      "class_id": 1,
      "detection_id": "text",
      "parent_id": "text",
      "class_confidence": 1,
      "points": [
        {
          "x": 1,
          "y": 1
        }
      ],
      "mask_format": "polygon"
    }
  ]
}

छवि पर मॉडल चलाएँ

Roboflow कई runtime के माध्यम से inference उपलब्ध कराता है - सही विकल्प इस बात पर निर्भर करता है कि आप एकल मॉडल या Workflow को कॉल कर रहे हैं, आपको कितना throughput चाहिए, और workload कहाँ चलता है।

यह पृष्ठ एक संक्षिप्त अवलोकन है। विस्तृत inference संदर्भ उत्पाद दस्तावेज़ीकरणमें मिलता है, जो उसी docs site का हिस्सा है। जहाँ विस्तृत सामग्री है, वहाँ cross-links दिए गए हैं।

Inference runtime

Runtime
कब उपयोग करें
संदर्भ

सर्वरलेस क्लाउड API (serverless.roboflow.com)

डिफ़ॉल्ट। होस्टेड, ऑटो-स्केलिंग, मॉडल्स और वर्कफ़्लोज़ का समर्थन करता है।

समर्पित डिप्लॉयमेंट्स

आपको पूर्वानुमेय latency, उच्च throughput, या pinned GPU type चाहिए। Roboflow द्वारा प्रबंधित।

Roboflow Inference (self-hosted)

ऑन-प्रिमाइसेस, edge devices, air-gapped environments, या ऐसे workloads जो आपकी VPC से बाहर नहीं जा सकते। ओपन सोर्स।

Serverless Cloud API को कॉल करना

एक मॉडल चलाएँ:

एक Workflow चलाएँ:

कुंजी को एक ?api_key= क्वेरी पैरामीटर के रूप में या api_key बॉडी फ़ील्ड विरासती चैनल है। यह अभी भी काम करता है, लेकिन Authorization: Bearer header आपकी कुंजी को URLs और लॉग्स से बाहर रखता है। देखें REST API के साथ प्रमाणीकरण करें.

लाइव वीडियो के लिए, देखें Serverless Video Streaming API. बड़े इमेज और वीडियो सेटों की असिंक्रोनस प्रोसेसिंग के लिए, देखें बैच प्रोसेसिंग.

अप्रचलित: Serverless v1

विरासती कार्य-विशिष्ट एंडपॉइंट्स - detect.roboflow.com, classify.roboflow.com, outline.roboflow.com, segment.roboflow.com - हैं अप्रचलित. वे पिछली संगतता के लिए अभी भी प्रतिक्रिया देते हैं, लेकिन नए कोड को serverless.roboflow.com इसके बजाय उपयोग करना चाहिए।

यदि आपको किसी स्निपेट में किसी *.roboflow.com कार्य होस्ट दिखाई दे, तो उसे विरासती मानें और उसे ऊपर दिए गए Serverless Cloud API फ़ॉर्म में रूपांतरित करें।

Python SDK

Python SDK के साथ उपयोग करें

यदि आप Python में काम कर रहे हैं, तो Serverless Cloud API के साथ इंटरैक्ट करने का सबसे सुविधाजनक तरीका Inference Python SDK का उपयोग करना है।

का उपयोग करने के लिए Inference SDK, पहले इसे इंस्टॉल करें:

Serverless Cloud API को अनुरोध भेजने के लिए, निम्न कोड का उपयोग करें:

ऊपर, अपना निर्दिष्ट करें मॉडल ID और API key. यह कोड आपका मॉडल चलाएगा और परिणाम लौटाएगा।

Roboflow Instant Model

Serverless Cloud API Roboflow Instant Modelचलाने का भी समर्थन करता है। आप Instant Model को किसी अन्य मॉडल की तरह चला सकते हैं, बस ध्यान दें कि confidence threshold Instant Models के लिए संवेदनशील हो सकता है।

एक इष्टतम confidence मॉडल को प्रशिक्षित की गई इमेजों की संख्या पर निर्भर करता है। इष्टतम confidence thresholds आम तौर पर 0.85 से 0.99 के बीच होते हैं।

configure(...) पूरे कॉन्फ़िगरेशन को बदल देता है, इसलिए api_key_transport को किसी भी कॉन्फ़िगरेशन में रखें जिसे आप लागू करते हैं।

Python SDK के साथ वीडियो स्ट्रीम करें

वीडियो पर object detection मॉडल चलाने के लिए Inference SDK WebRTC क्लाइंट का उपयोग करें। Serverless Video Streaming API वीडियो को Roboflow Cloud में प्रोसेस करता है और हर फ़्रेम के लिए predictions लौटाता है।

SDK को उसके WebRTC dependencies के साथ और supervision:

बदलें API_KEY और model-id/1 को अपनी API key और model ID से बदलें। जानें कि webcams और RTSP cameras से stream कैसे करें, हर फ़्रेम को process कैसे करें, या Serverless Video Streaming API गाइड.

CLI

आप Roboflow पर प्रशिक्षित मॉडल चलाने के लिए Roboflow CLI का उपयोग कर सकते हैं, या Roboflow Universe.

चलाकर roboflow infer कमांड लाइन में, CLI इमेज को Roboflow API पर भेजता है और predictions प्रिंट करता है।

कमांड

विकल्प

फ़्लैग
विवरण

-m, --model

में मॉडल ID project/version फ़ॉर्मेट (आवश्यक)

-c, --confidence

Confidence threshold, 0.0–1.0 (डिफ़ॉल्ट: 0.5)

-o, --overlap

Overlap/NMS threshold, 0.0–1.0 (डिफ़ॉल्ट: 0.5)

-t, --type

मॉडल प्रकार (auto-detection छोड़ें): ऑब्जेक्ट डिटेक्शन, वर्गीकरण, इंस्टेंस सेगमेंटेशन, सिमैंटिक सेगमेंटेशन, कीपॉइंट डिटेक्शन

उदाहरण

Roboflow Universe से किसी open source मॉडल का उपयोग करके inference चलाएँ - उदाहरण के लिए, poker-cards डेटासेट:

वर्कस्पेस डिफ़ॉल्ट रूप से आपके कॉन्फ़िगर किए गए वर्कस्पेस पर सेट होता है। किसी अलग वर्कस्पेस से मॉडल उपयोग करने के लिए:

auto-detection API call को छोड़ने के लिए मॉडल प्रकार निर्दिष्ट करें:

JSON आउटपुट

उपयोग करें --json स्क्रिप्टिंग और ऑटोमेशन के लिए संरचित prediction डेटा प्राप्त करने हेतु:

सभी समर्थित पैरामीटर देखें roboflow infer --help.

MCP सर्वर

अपने AI एजेंट को MCP सर्वर और यह इन टूल्स के साथ एक इमेज पर मॉडल चला सकता है:

टूल
विवरण

models_infer

प्रशिक्षित मॉडल का उपयोग करके एक इमेज पर hosted inference चलाएँ।

workflows_run

एक या अधिक इमेजों पर सहेजा गया Workflow निष्पादित करें।

project_deployment_run

प्रोजेक्ट के स्थिर live endpoint के माध्यम से inference चलाएँ।

अंतिम अपडेट

क्या यह उपयोगी था?