Serverless Cloud API
Roboflow cloud में GPU-accelerated auto-scaling infrastructure पर Workflows और Model Inference चलाएँ।
के बारे में
Roboflow पर परिनियोजित मॉडलों के लिए एक REST API उपलब्ध है, जिसके माध्यम से आप छवियों पर इनफ़ेरेंस चला सकते हैं। यह परिनियोजन विधि उन वातावरणों के लिए आदर्श है जहाँ आपके परिनियोजन डिवाइस पर स्थायी इंटरनेट कनेक्शन हो।
ऐप में, इस एंडपॉइंट को "Serverless Cloud API" कहा जाता है, या जहाँ जगह कम हो (जैसे: Workflow editor runtime picker) वहाँ "Cloud API"। एक समर्पित परिनियोजन एंडपॉइंट (*.roboflow.cloud) को "Dedicated Cloud API" कहा जाता है, और पुराने v1 एंडपॉइंट को "Hosted API (Legacy)" कहा जाता है। ये लेबल पहले के "Serverless Hosted API" और "Serverless API V2" नामों की जगह लेते हैं।
आप Serverless Cloud API का उपयोग कर सकते हैं:
के साथ Inference Python SDK
Inference सर्वर
हमारा Serverless Cloud API द्वारा संचालित है Inference Server. इसका मतलब है कि आप नीचे दिखाए अनुसार हमारे Serverless Cloud API और self-hosting विकल्प के बीच और वापस आसानी से स्विच कर सकते हैं:
from inference_sdk import InferenceHTTPClient, InferenceConfiguration
CLIENT = InferenceHTTPClient(
# api_url="http://localhost:9001" # स्व-होस्टेड Inference सर्वर
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 ट्रांसपोर्ट.
सीमाएँ
छवि इनफ़ेरेंस का बिल प्रति छवि क्रेडिट्स में, मॉडल द्वारा निर्धारित दर पर लगाया जाता है। देखें मूल्य निर्धारण और मॉडल मूल्य निर्धारण.
हमारा Serverless Cloud API 20MB तक की फ़ाइल अपलोड का समर्थन करता है। उच्च रिज़ॉल्यूशन वाली छवियों के साथ आपको सीमाएँ आ सकती हैं। यदि आपको कोई समस्या हो, तो कृपया अपने एंटरप्राइज़ सपोर्ट संपर्क से संपर्क करें या संदेश पोस्ट करें फोरम.
देखें Serverless Cloud API v1 पुराने API दस्तावेज़ के लिए।
HTTP API
REST API के साथ उपयोग करें
Serverless Cloud API में सभी मॉडलों और Workflows के लिए एक ही एंडपॉइंट है:
HTTP एंडपॉइंट
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.
ID of a Roboflow dataset corresponding to the model to use for inference OR workspace ID
ID of a Roboflow dataset version corresponding to the model to use for inference OR model ID
Roboflow API Key that will be passed to the model during initialization for artifact retrieval
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.
0.4The confidence threshold used to filter out keypoints that are not visible based on model confidence
0One 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.
jsonThe publically accessible URL of an image to use for inference.
One of base64 or numpy. Note, numpy input is not supported for Roboflow Hosted Inference.
base64Action 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.
Action recognition: return raw scored candidates
falseIf true, labels will be include in any inference visualization.
falseOne 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.
accurateOpt into mask_decode_mode and tradeoff_factor on inference_models. Otherwise masks stay at image resolution. Legacy backend decoding is unchanged.
falseThe amount to tradeoff between 0='fast' and 1='accurate'
0The 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.
300The IoU threhsold that must be met for a box pair to be considered duplicate during NMS
0.3The stroke width used when visualizing predictions
1If true, disables automatic image orientation
falseIf true, disables automatic contrast adjustment
falseIf true, disables automatic grayscale conversion
falseIf true, disables automatic static crop
falseIf true, the predictions will be prevented from registration by Active Learning (if the functionality is enabled)
falseParameter to be used when Active Learning data registration should happen against different dataset than the one pointed by model_id
Anomaly detection only: include the raw anomaly heatmap at the network input resolution
falseThe source of the inference request
externalThe detailed source information of the inference request
externalThe format of the prediction mask - polygon (default) or rle - applicable for instance segmentation models.
polygonPossible values: Successful Response
Validation Error
POST /{dataset_id}/{version_id} HTTP/1.1
Accept: */*
{
"visualization": "text",
"inference_id": "text",
"frame_id": 1,
"time": 1,
"resolved_model": {
"model_id": "text",
"model_package_id": "text",
"backend": "text",
"quantization": "text"
},
"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"
}
],
"original_image": {
"width": 1,
"height": 1
},
"mask_metadata": {
"coordinate_system": "mask_grid",
"width": 160,
"height": 107,
"scale_x": 4,
"scale_y": 4
}
}किसी छवि पर मॉडल चलाएँ
Roboflow कई runtime के माध्यम से inference उपलब्ध कराता है - सही विकल्प इस पर निर्भर करता है कि आप एक अकेले मॉडल को कॉल कर रहे हैं या एक Workflow को, आपको कितने throughput की ज़रूरत है, और workload कहाँ चलता है।
यह पृष्ठ एक संक्षिप्त अवलोकन है। विस्तृत inference संदर्भ में उपलब्ध है उत्पाद दस्तावेज़ीकरण, जो उसी docs साइट का हिस्सा है। गहन सामग्री जहाँ है, वहाँ क्रॉस-लिंक दिए गए हैं।
Inference रनटाइम
Serverless Cloud API (serverless.roboflow.com)
डिफ़ॉल्ट। होस्टेड, ऑटो-स्केलिंग, मॉडलों और Workflows का समर्थन करता है।
समर्पित परिनियोजन
आपको पूर्वानुमेय latency, उच्च throughput, या pinned GPU प्रकार की आवश्यकता है। Roboflow द्वारा प्रबंधित।
Roboflow Inference (self-hosted)
ऑन-प्रेम, edge डिवाइस, air-gapped वातावरण, या ऐसे workload जो आपके VPC से बाहर नहीं जा सकते। ओपन सोर्स।
Serverless Cloud API को कॉल करना
एक मॉडल चलाएँ:
एक Workflow चलाएँ:
लाइव वीडियो के लिए, देखें 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 को अनुरोध भेजने के लिए, निम्न कोड का उपयोग करें:
ऊपर, अपना model ID और API key. यह कोड आपका मॉडल चलाएगा और परिणाम लौटाएगा।
Roboflow Instant Model
Serverless Cloud API Roboflow को चलाने का भी समर्थन करता है Instant Model. आप Instant Model को किसी भी अन्य मॉडल की तरह चला सकते हैं, बस ध्यान दें कि confidence threshold Instant Models के लिए संवेदनशील हो सकता है।
configure(...) पूरी कॉन्फ़िगरेशन को बदल देता है, इसलिए api_key_transport को किसी भी कॉन्फ़िगरेशन में रखें जिसे आप लागू करते हैं।
Python SDK के साथ वीडियो स्ट्रीम करें
वीडियो पर एक object detection model चलाने के लिए Inference SDK WebRTC client का उपयोग करें। Serverless Video Streaming API वीडियो को Roboflow Cloud में संसाधित करता है और प्रत्येक frame के लिए predictions लौटाता है।
SDK को इसके WebRTC dependencies और supervision:
बदलें API_KEY और model-id/1 को अपनी API key और model ID से। जानें कि वेबकैम और RTSP कैमरों से स्ट्रीम कैसे करें, हर frame को कैसे संसाधित करें, या Serverless Video Streaming API गाइड.
CLI
आप Roboflow CLI का उपयोग Roboflow पर प्रशिक्षित मॉडल या Roboflow Universe पर उपलब्ध open source models के साथ चलाने के लिए कर सकते हैं। Roboflow Universe.
चलाकर roboflow infer कमांड लाइन में, CLI छवि को Roboflow API पर भेजता है और predictions प्रिंट करता है।
कमांड
विकल्प
-m, --model
में model ID project/version फ़ॉर्मेट (आवश्यक)
-c, --confidence
विश्वास सीमा, 0.0–1.0 (डिफ़ॉल्ट: 0.5)
-o, --overlap
ओवरलैप/NMS सीमा, 0.0–1.0 (डिफ़ॉल्ट: 0.5)
-t, --type
मॉडल प्रकार (स्वतः-पहचान छोड़ें): object-detection, classification, instance-segmentation, semantic-segmentation, keypoint-detection
उदाहरण
Roboflow Universe के एक open source model का उपयोग करके inference चलाएँ - उदाहरण के लिए, poker-cards डेटासेट:
वर्कस्पेस डिफ़ॉल्ट रूप से आपका कॉन्फ़िगर किया हुआ workspace होता है। किसी अलग workspace के मॉडल का उपयोग करने के लिए:
स्वतः-पहचान API कॉल को छोड़ने के लिए model type निर्दिष्ट करें:
JSON आउटपुट
उपयोग करें --json स्क्रिप्टिंग और ऑटोमेशन के लिए संरचित prediction data प्राप्त करने हेतु:
सभी समर्थित पैरामीटर के लिए देखें roboflow infer --help.
MCP सर्वर
अपने AI agent को MCP सर्वर से जोड़ें और यह इन टूल्स के साथ किसी छवि पर मॉडल चला सकता है:
models_infer
प्रशिक्षित मॉडल का उपयोग करके किसी छवि पर hosted inference चलाएँ।
workflows_run
एक या अधिक छवियों पर सहेजा गया Workflow निष्पादित करें।
project_deployment_run
प्रोजेक्ट के स्थिर live endpoint के माध्यम से inference चलाएँ।
अंतिम अपडेट
क्या यह उपयोगी था?