Ultralytics HUB Inference API
모델을 훈련한 후 공유 Inference API를 무료로 사용할 수 있습니다. Pro 사용자라면 전용 Inference API에 액세스할 수 있습니다. Ultralytics HUB Inference API를 사용하면 Ultralytics YOLO 환경을 로컬에 설치하고 설정할 필요 없이 REST API를 통해 추론을 실행할 수 있습니다.
참고: Ultralytics HUB Inference API 둘러보기
전용 Inference API
높은 수요와 광범위한 관심에 부응하여 Ultralytics HUB 전용 Inference API를 공개하게 되어 기쁩니다. Pro 사용자를 위해 전용 환경에서 단 한 번의 클릭으로 배포할 수 있습니다!
참고
Pro Plan의 일부로 공개 베타 기간 동안 이 기능을 무료로 제공하게 되어 기쁩니다. 향후 유료 티어가 추가될 수 있습니다.
- 글로벌 커버리지: 전 세계 38개 지역에 배포되어 어느 위치에서든 낮은 지연 시간으로 액세스할 수 있습니다. Google Cloud 전체 지역 목록을 확인하세요.
- Google Cloud Run 기반: Google Cloud Run을 기반으로 하여 무한대로 확장 가능하고 매우 안정적인 인프라를 제공합니다.
- 고속: Ultralytics 테스트에 따르면 인접 지역에서 640 해상도로 YOLOv8n 추론 시 100ms 미만의 지연 시간이 가능합니다.
- 향상된 보안: 데이터 보호를 위한 강력한 보안 기능을 제공하고 산업 표준 준수를 보장합니다. Google Cloud 보안에 대해 자세히 알아보세요.
Ultralytics HUB 전용 추론 API를 사용하려면 Start Endpoint 버튼을 클릭하세요. 그런 다음 아래 가이드에 설명된 대로 고유한 엔드포인트 URL을 사용합니다.
팁
설명서에 설명된 대로 최상의 성능을 위해 지연 시간이 가장 짧은 지역을 선택하세요.
전용 엔드포인트를 종료하려면 Stop Endpoint 버튼을 클릭하세요.
공유 Inference API
Ultralytics HUB 공유 추론 API를 사용하려면 아래 가이드를 따르세요.
Ultralytics HUB 공유 추론 API에는 다음과 같은 사용 제한이 있습니다.
- 시간당 100회 호출
Python
python을 사용하여 Ultralytics HUB 추론 API에 액세스하려면 다음 코드를 사용하세요.
import requests
# API URL
url = "https://predict.ultralytics.com"
# Headers, use actual API_KEY
headers = {"x-api-key": "API_KEY"}
# Inference arguments (use actual MODEL_ID)
data = {"model": "https://hub.ultralytics.com/models/MODEL_ID", "imgsz": 640, "conf": 0.25, "iou": 0.45}
# Load image and send request
with open("path/to/image.jpg", "rb") as image_file:
files = {"file": image_file}
response = requests.post(url, headers=headers, files=files, data=data)
print(response.json())
참고
다음을 대체하십시오. MODEL_ID
원하는 모델 ID로, API_KEY
실제 API 키로, 그리고 path/to/image.jpg
추론을 실행할 이미지의 경로로.
Ultralytics에서 제공하는 전용 Inference API를 사용하는 경우, url
도 함께 교체하세요.
cURL
cURL을 사용하여 Ultralytics HUB 추론 API에 액세스하려면 다음 코드를 사용하세요.
curl -X POST "https://predict.ultralytics.com" \
-H "x-api-key: API_KEY" \
-F "model=https://hub.ultralytics.com/models/MODEL_ID" \
-F "file=@/path/to/image.jpg" \
-F "imgsz=640" \
-F "conf=0.25" \
-F "iou=0.45"
참고
다음을 대체하십시오. MODEL_ID
원하는 모델 ID로, API_KEY
실제 API 키로, 그리고 path/to/image.jpg
추론을 실행할 이미지의 경로로.
Ultralytics에서 제공하는 전용 Inference API를 사용하는 경우, url
도 함께 교체하세요.
인수
사용 가능한 추론 인수에 대한 전체 목록은 아래 표를 참조하세요.
인수 | 기본값 | 유형 | 설명 |
---|---|---|---|
file |
file |
추론에 사용할 이미지 또는 비디오 파일입니다. | |
imgsz |
640 |
int |
입력 이미지의 크기이며 유효한 범위는 32 - 1280 픽셀입니다. |
conf |
0.25 |
float |
예측에 대한 신뢰도 임계값, 유효 범위 0.01 - 1.0 . |
iou |
0.45 |
float |
Intersection over Union (IoU) 임계값, 유효 범위 0.0 - 0.95 . |
응답
Ultralytics HUB 추론 API는 JSON 응답을 반환합니다.
분류
분류 모델
from ultralytics import YOLO
# Load model
model = YOLO("yolov8n-cls.pt")
# Run inference
results = model("image.jpg")
# Print image.jpg results in JSON format
print(results[0].to_json())
curl -X POST "https://predict.ultralytics.com" \
-H "x-api-key: API_KEY" \
-F "model=https://hub.ultralytics.com/models/MODEL_ID" \
-F "file=@/path/to/image.jpg" \
-F "imgsz=640" \
-F "conf=0.25" \
-F "iou=0.45"
import requests
# API URL
url = "https://predict.ultralytics.com"
# Headers, use actual API_KEY
headers = {"x-api-key": "API_KEY"}
# Inference arguments (use actual MODEL_ID)
data = {"model": "https://hub.ultralytics.com/models/MODEL_ID", "imgsz": 640, "conf": 0.25, "iou": 0.45}
# Load image and send request
with open("path/to/image.jpg", "rb") as image_file:
files = {"file": image_file}
response = requests.post(url, headers=headers, files=files, data=data)
print(response.json())
{
"images": [
{
"results": [
{
"class": 0,
"name": "person",
"confidence": 0.92
}
],
"shape": [
750,
600
],
"speed": {
"inference": 200.8,
"postprocess": 0.8,
"preprocess": 2.8
}
}
],
"metadata": ...
}
객체 탐지
객체 탐지 모델
from ultralytics import YOLO
# Load model
model = YOLO("yolov8n.pt")
# Run inference
results = model("image.jpg")
# Print image.jpg results in JSON format
print(results[0].to_json())
curl -X POST "https://predict.ultralytics.com" \
-H "x-api-key: API_KEY" \
-F "model=https://hub.ultralytics.com/models/MODEL_ID" \
-F "file=@/path/to/image.jpg" \
-F "imgsz=640" \
-F "conf=0.25" \
-F "iou=0.45"
import requests
# API URL
url = "https://predict.ultralytics.com"
# Headers, use actual API_KEY
headers = {"x-api-key": "API_KEY"}
# Inference arguments (use actual MODEL_ID)
data = {"model": "https://hub.ultralytics.com/models/MODEL_ID", "imgsz": 640, "conf": 0.25, "iou": 0.45}
# Load image and send request
with open("path/to/image.jpg", "rb") as image_file:
files = {"file": image_file}
response = requests.post(url, headers=headers, files=files, data=data)
print(response.json())
{
"images": [
{
"results": [
{
"class": 0,
"name": "person",
"confidence": 0.92,
"box": {
"x1": 118,
"x2": 416,
"y1": 112,
"y2": 660
}
}
],
"shape": [
750,
600
],
"speed": {
"inference": 200.8,
"postprocess": 0.8,
"preprocess": 2.8
}
}
],
"metadata": ...
}
OBB
OBB 모델
from ultralytics import YOLO
# Load model
model = YOLO("yolov8n-obb.pt")
# Run inference
results = model("image.jpg")
# Print image.jpg results in JSON format
print(results[0].tojson())
curl -X POST "https://predict.ultralytics.com" \
-H "x-api-key: API_KEY" \
-F "model=https://hub.ultralytics.com/models/MODEL_ID" \
-F "file=@/path/to/image.jpg" \
-F "imgsz=640" \
-F "conf=0.25" \
-F "iou=0.45"
import requests
# API URL
url = "https://predict.ultralytics.com"
# Headers, use actual API_KEY
headers = {"x-api-key": "API_KEY"}
# Inference arguments (use actual MODEL_ID)
data = {"model": "https://hub.ultralytics.com/models/MODEL_ID", "imgsz": 640, "conf": 0.25, "iou": 0.45}
# Load image and send request
with open("path/to/image.jpg", "rb") as image_file:
files = {"file": image_file}
response = requests.post(url, headers=headers, files=files, data=data)
print(response.json())
{
"images": [
{
"results": [
{
"class": 0,
"name": "person",
"confidence": 0.92,
"box": {
"x1": 374.85565,
"x2": 392.31824,
"x3": 412.81805,
"x4": 395.35547,
"y1": 264.40704,
"y2": 267.45728,
"y3": 150.0966,
"y4": 147.04634
}
}
],
"shape": [
750,
600
],
"speed": {
"inference": 200.8,
"postprocess": 0.8,
"preprocess": 2.8
}
}
],
"metadata": ...
}
Segmentation
분할 모델
from ultralytics import YOLO
# Load model
model = YOLO("yolov8n-seg.pt")
# Run inference
results = model("image.jpg")
# Print image.jpg results in JSON format
print(results[0].tojson())
curl -X POST "https://predict.ultralytics.com" \
-H "x-api-key: API_KEY" \
-F "model=https://hub.ultralytics.com/models/MODEL_ID" \
-F "file=@/path/to/image.jpg" \
-F "imgsz=640" \
-F "conf=0.25" \
-F "iou=0.45"
import requests
# API URL
url = "https://predict.ultralytics.com"
# Headers, use actual API_KEY
headers = {"x-api-key": "API_KEY"}
# Inference arguments (use actual MODEL_ID)
data = {"model": "https://hub.ultralytics.com/models/MODEL_ID", "imgsz": 640, "conf": 0.25, "iou": 0.45}
# Load image and send request
with open("path/to/image.jpg", "rb") as image_file:
files = {"file": image_file}
response = requests.post(url, headers=headers, files=files, data=data)
print(response.json())
{
"images": [
{
"results": [
{
"class": 0,
"name": "person",
"confidence": 0.92,
"box": {
"x1": 118,
"x2": 416,
"y1": 112,
"y2": 660
},
"segments": {
"x": [
266.015625,
266.015625,
258.984375,
...
],
"y": [
110.15625,
113.67188262939453,
120.70311737060547,
...
]
}
}
],
"shape": [
750,
600
],
"speed": {
"inference": 200.8,
"postprocess": 0.8,
"preprocess": 2.8
}
}
],
"metadata": ...
}
포즈
포즈 모델
from ultralytics import YOLO
# Load model
model = YOLO("yolov8n-pose.pt")
# Run inference
results = model("image.jpg")
# Print image.jpg results in JSON format
print(results[0].tojson())
curl -X POST "https://predict.ultralytics.com" \
-H "x-api-key: API_KEY" \
-F "model=https://hub.ultralytics.com/models/MODEL_ID" \
-F "file=@/path/to/image.jpg" \
-F "imgsz=640" \
-F "conf=0.25" \
-F "iou=0.45"
import requests
# API URL
url = "https://predict.ultralytics.com"
# Headers, use actual API_KEY
headers = {"x-api-key": "API_KEY"}
# Inference arguments (use actual MODEL_ID)
data = {"model": "https://hub.ultralytics.com/models/MODEL_ID", "imgsz": 640, "conf": 0.25, "iou": 0.45}
# Load image and send request
with open("path/to/image.jpg", "rb") as image_file:
files = {"file": image_file}
response = requests.post(url, headers=headers, files=files, data=data)
print(response.json())
{
"images": [
{
"results": [
{
"class": 0,
"name": "person",
"confidence": 0.92,
"box": {
"x1": 118,
"x2": 416,
"y1": 112,
"y2": 660
},
"keypoints": {
"visible": [
0.9909399747848511,
0.8162999749183655,
0.9872099757194519,
...
],
"x": [
316.3871765136719,
315.9374694824219,
304.878173828125,
...
],
"y": [
156.4207763671875,
148.05775451660156,
144.93240356445312,
...
]
}
}
],
"shape": [
750,
600
],
"speed": {
"inference": 200.8,
"postprocess": 0.8,
"preprocess": 2.8
}
}
],
"metadata": ...
}