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

서버리스 클라우드 API

Roboflow 클라우드의 GPU 가속 자동 확장 인프라에서 워크플로와 모델 추론을 실행합니다.

소개

Roboflow에 배포된 모델에는 이미지를 대상으로 추론을 실행할 수 있는 REST API가 제공됩니다. 이 배포 방법은 배포 기기에서 지속적인 인터넷 연결이 있는 환경에 적합합니다.

앱에서 이 엔드포인트는 "Serverless Cloud API"로 표시되며, 공간이 부족한 경우(예: Workflow 편집기 런타임 선택기)에는 "Cloud API"로 표시됩니다. A 전용 배포 엔드포인트 (*.roboflow.cloud)는 "Dedicated Cloud API"로 표시되며, 이전 v1 엔드포인트는 "Hosted API (Legacy)"로 표시됩니다. 이러한 레이블은 이전의 "Serverless Hosted API" 및 "Serverless API V2" 이름을 대체합니다.

Serverless Cloud API는 다음과 같이 사용할 수 있습니다:

Inference 서버

우리의 Serverless Cloud API는 다음의 지원을 받습니다. Inference Server. 이는 아래와 같이 Serverless Cloud API와 자체 호스팅 옵션을 쉽게 전환할 수 있음을 의미합니다:

from inference_sdk import InferenceHTTPClient

CLIENT = InferenceHTTPClient(
    # api_url="http://localhost:9001" # 자체 호스팅된 Inference 서버
    api_url="https://serverless.roboflow.com", # 우리의 Serverless Cloud API
    api_key="API_KEY" # 비공개 모델과 데이터에 접근하기 위한 선택 사항
)

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

제한 사항

우리의 Serverless Cloud API는 최대 20MB까지의 파일 업로드를 지원합니다. 더 높은 해상도의 이미지에서는 제한에 걸릴 수 있습니다. 문제가 발생하면 엔터프라이즈 지원 담당자에게 문의하거나 다음에 메시지를 게시해 주세요. 포럼.

요청이 너무 큰 경우, 첨부된 이미지를 축소하는 것을 권장합니다. 이미지는 서버에서 수신된 후 모델 아키텍처가 허용하는 입력 크기로 어차피 축소되므로, 일반적으로 성능 저하가 발생하지 않습니다. Python SDK와 같은 일부 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
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는 여러 런타임을 통해 추론 기능을 제공합니다. 어떤 것을 선택할지는 단일 모델을 호출하는지 워크플로우를 호출하는지, 필요한 처리량이 어느 정도인지, 그리고 작업이 어디에서 실행되는지에 따라 달라집니다.

이 페이지는 간략한 개요입니다. 자세한 추론 레퍼런스는 다음에 있습니다. 제품 문서, 이는 같은 문서 사이트의 일부입니다. 더 자세한 자료가 있는 곳에는 상호 링크가 제공됩니다.

추론 런타임

런타임
다음 경우 사용
참조

서버리스 클라우드 API (serverless.roboflow.com)

기본값. 호스팅됨, 자동 확장, 모델 및 워크플로우 지원.

전용 배포

예측 가능한 지연 시간, 높은 처리량 또는 고정된 GPU 유형이 필요합니다. Roboflow가 관리합니다.

Roboflow Inference (자가 호스팅)

온프레미스, 엣지 디바이스, 에어갭 환경 또는 VPC 밖으로 나갈 수 없는 작업 부하. 오픈 소스.

Serverless Cloud API 호출하기

모델 실행:

워크플로우 실행:

라이브 비디오에 대해서는 다음을 참조하세요. 서버리스 비디오 스트리밍 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에 요청하려면 다음 코드를 사용하세요:

위에서 다음을 지정하세요. 모델 IDAPI 키. 이 코드는 모델을 실행하고 결과를 반환합니다.

Roboflow Instant Model

Serverless Cloud API는 또한 Roboflow Instant Model실행도 지원합니다. Instant Model은 다른 모델과 마찬가지로 실행할 수 있지만, 신뢰도 임계값은 Instant Model에서 민감할 수 있습니다.

최적의 신뢰도는 모델이 학습한 이미지 수에 따라 달라집니다. 최적의 신뢰도 임계값은 일반적으로 0.85에서 0.99 사이입니다.

Python SDK로 비디오 스트리밍

Inference SDK WebRTC 클라이언트를 사용하여 비디오에서 객체 감지 모델을 실행하세요. Serverless Video Streaming API는 Roboflow Cloud에서 비디오를 처리하고 각 프레임에 대한 예측을 반환합니다.

WebRTC 종속성과 함께 SDK를 설치하고 supervision:

다음으로 바꾸세요 API_KEYmodel-id/1 를 API 키와 모델 ID로 바꾸세요. 웹캠과 RTSP 카메라에서 스트리밍하고, 모든 프레임을 처리하거나, 다음에서 워크플로우를 실행하는 방법을 알아보세요. Serverless Video Streaming API 가이드.

CLI

Roboflow에서 학습한 모델이나 다음에서 제공되는 오픈 소스 모델로 Roboflow CLI를 사용해 실행할 수 있습니다. Roboflow Universe.

다음을 실행하면 roboflow infer 명령줄에서 CLI가 이미지를 Roboflow API로 보내고 예측을 출력합니다.

명령

옵션

플래그
설명

-m, --model

다음 형식의 모델 ID project/version 형식(필수)

-c, --confidence

신뢰도 임계값, 0.0–1.0(기본값: 0.5)

-o, --overlap

겹침/NMS 임계값, 0.0–1.0(기본값: 0.5)

-t, --type

모델 유형(자동 감지 건너뜀): 객체 감지, 분류, 인스턴스 분할, 시맨틱 분할, 키포인트 감지

예시

Roboflow Universe의 오픈 소스 모델을 사용하여 추론을 실행하세요 - 예를 들어, 포커 카드 데이터셋:

기본적으로 작업 공간은 구성된 작업 공간으로 설정됩니다. 다른 작업 공간의 모델을 사용하려면:

자동 감지 API 호출을 건너뛰려면 모델 유형을 지정하세요:

JSON 출력

다음을 사용하여 --json 을 사용해 스크립팅과 자동화를 위한 구조화된 예측 데이터를 가져오세요:

다음으로 지원되는 모든 매개변수를 확인하세요 roboflow infer --help.

마지막 업데이트

도움이 되었나요?