์ฝ˜ํ…์ธ ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

Ultralytics HUB ์ถ”๋ก  API

๋ชจ๋ธ์„ ํ•™์Šตํ•œ ํ›„์—๋Š” ๊ณต์œ  ์ถ”๋ก  API๋ฅผ ๋ฌด๋ฃŒ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Pro ์‚ฌ์šฉ์ž์˜ ๊ฒฝ์šฐ, ์ „์šฉ ์ถ”๋ก  API์— ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Ultralytics HUB ์ถ”๋ก  API๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด Ultralytics YOLO ํ™˜๊ฒฝ์„ ๋กœ์ปฌ์— ์„ค์น˜ ๋ฐ ์„ค์ •ํ•  ํ•„์š” ์—†์ด REST API๋ฅผ ํ†ตํ•ด ์ถ”๋ก ์„ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Ultralytics ๋ชจ๋ธ ํŽ˜์ด์ง€ ๋‚ด๋ถ€์˜ ๋ฐฐํฌ ํƒญ ์Šคํฌ๋ฆฐ์ƒท์—์„œ ์ „์šฉ ์ถ”๋ก  API ์นด๋“œ๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š” ํ™”์‚ดํ‘œ์™€ ๊ณต์œ  ์ถ”๋ก  API ์นด๋“œ๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š” ํ™”์‚ดํ‘œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.


Watch: Ultralytics HUB ์ถ”๋ก  API ์—ฐ์Šต

์ „์šฉ ์ถ”๋ก  API

๋†’์€ ์ˆ˜์š”์™€ ํญ๋„“์€ ๊ด€์‹ฌ์— ๋ถ€์‘ํ•˜์—ฌ, ํ”„๋กœ ์‚ฌ์šฉ์ž๋ฅผ ์œ„ํ•œ ์ „์šฉ ํ™˜๊ฒฝ์—์„œ ํด๋ฆญ ํ•œ ๋ฒˆ์œผ๋กœ ๋ฐฐํฌํ•  ์ˆ˜ ์žˆ๋Š” Ultralytics HUB ์ „์šฉ ์ถ”๋ก  API๋ฅผ ๊ณต๊ฐœํ•˜๊ฒŒ ๋˜์–ด ๋งค์šฐ ๊ธฐ์˜๊ฒŒ ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค!

์ฐธ๊ณ 

ํ”„๋กœ ์š”๊ธˆ์ œ์˜ ์ผ๋ถ€๋กœ ๊ณต๊ฐœ ๋ฒ ํƒ€ ๋ฒ„์ „์—์„œ ์ด ๊ธฐ๋Šฅ์„ ๋ฌด๋ฃŒ๋กœ ์ œ๊ณตํ•˜๊ฒŒ ๋˜์–ด ๊ธฐ์˜๊ฒŒ ์ƒ๊ฐํ•˜๋ฉฐ, ํ–ฅํ›„ ์œ ๋ฃŒํ™”ํ•  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค.

  • ๊ธ€๋กœ๋ฒŒ ์„œ๋น„์Šค ๋ฒ”์œ„: ์ „ ์„ธ๊ณ„ 38๊ฐœ ์ง€์—ญ์— ๋ฐฐํฌ๋˜์–ด ์–ด๋Š ์œ„์น˜์—์„œ๋‚˜ ์ง€์—ฐ ์‹œ๊ฐ„์ด ์งง์€ ์•ก์„ธ์Šค๋ฅผ ๋ณด์žฅํ•ฉ๋‹ˆ๋‹ค. Google ํด๋ผ์šฐ๋“œ ๋ฆฌ์ „ ์ „์ฒด ๋ชฉ๋ก ๋ณด๊ธฐ.
  • Google ํด๋ผ์šฐ๋“œ ๋Ÿฐ ์ง€์›: ๋ฌดํ•œํ•œ ํ™•์žฅ์„ฑ๊ณผ ๋†’์€ ์•ˆ์ •์„ฑ์˜ ์ธํ”„๋ผ๋ฅผ ์ œ๊ณตํ•˜๋Š” Google Cloud Run์˜ ์ง€์›์„ ๋ฐ›์Šต๋‹ˆ๋‹ค.
  • ๋น ๋ฅธ ์†๋„: Ultralytics ํ…Œ์ŠคํŠธ ๊ฒฐ๊ณผ, ์ธ๊ทผ ์ง€์—ญ์—์„œ 640 ํ•ด์ƒ๋„๋กœ YOLOv8n ์ถ”๋ก  ์‹œ 100ms ๋ฏธ๋งŒ์˜ ์ง€์—ฐ ์‹œ๊ฐ„์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.
  • ๊ฐ•ํ™”๋œ ๋ณด์•ˆ: ๊ฐ•๋ ฅํ•œ ๋ณด์•ˆ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ ๋ณดํ˜ธํ•˜๊ณ  ์—…๊ณ„ ํ‘œ์ค€์„ ์ค€์ˆ˜ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. Google ํด๋ผ์šฐ๋“œ ๋ณด์•ˆ์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด์„ธ์š”.

Ultralytics HUB ์ „์šฉ ์ถ”๋ก  API๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ์—”๋“œํฌ์ธํŠธ ์‹œ์ž‘ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ ๋‹ค์Œ ์•„๋ž˜ ๊ฐ€์ด๋“œ์— ์„ค๋ช…๋œ ๋Œ€๋กœ ๊ณ ์œ ํ•œ ์—”๋“œํฌ์ธํŠธ URL์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

Ultralytics ๋ชจ๋ธ ํŽ˜์ด์ง€ ๋‚ด ๋ฐฐํฌ ํƒญ์˜ ํ—ˆ๋ธŒ ์Šคํฌ๋ฆฐ์ƒท๊ณผ ์ „์šฉ ์ถ”๋ก  API ์นด๋“œ์˜ ์‹œ์ž‘ ์—”๋“œํฌ์ธํŠธ ๋ฒ„ํŠผ์„ ๊ฐ€๋ฆฌํ‚ค๋Š” ํ™”์‚ดํ‘œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

ํŒ

์„ค๋ช…์„œ์— ์„ค๋ช…๋œ ๋Œ€๋กœ ์ตœ์ƒ์˜ ์„ฑ๋Šฅ์„ ์œ„ํ•ด ์ง€์—ฐ ์‹œ๊ฐ„์ด ๊ฐ€์žฅ ์งง์€ ์ง€์—ญ์„ ์„ ํƒํ•˜์„ธ์š”.

์ „์šฉ ์—”๋“œํฌ์ธํŠธ๋ฅผ ์ข…๋ฃŒํ•˜๋ ค๋ฉด ์—”๋“œํฌ์ธํŠธ ์ค‘์ง€ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

Ultralytics ๋ชจ๋ธ ํŽ˜์ด์ง€ ๋‚ด๋ถ€์˜ ๋ฐฐํฌ ํƒญ ์Šคํฌ๋ฆฐ์ƒท๊ณผ ์ „์šฉ ์ถ”๋ก  API ์นด๋“œ์˜ ์—”๋“œํฌ์ธํŠธ ์ค‘์ง€ ๋ฒ„ํŠผ์„ ๊ฐ€๋ฆฌํ‚ค๋Š” ํ™”์‚ดํ‘œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

๊ณต์œ  ์ถ”๋ก  API

Ultralytics HUB ๊ณต์œ  ์ถ”๋ก  API๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ์•„๋ž˜ ๊ฐ€์ด๋“œ๋ฅผ ๋”ฐ๋ฅด์„ธ์š”.

๋ฌด๋ฃŒ ์‚ฌ์šฉ์ž์—๊ฒŒ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์‚ฌ์šฉ ์ œํ•œ์ด ์žˆ์Šต๋‹ˆ๋‹ค:

  • ์‹œ๊ฐ„๋‹น 100 ํ†ตํ™”
  • ์›” 1,000 ํ†ตํ™”

ํ”„๋กœ ์‚ฌ์šฉ์ž์—๊ฒŒ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์‚ฌ์šฉ ์ œํ•œ์ด ์žˆ์Šต๋‹ˆ๋‹ค:

  • ์‹œ๊ฐ„๋‹น 1,000 ํ†ตํ™”
  • ์›” 10000 ํ†ตํ™”

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 ๋ฅผ ์ถ”๋ก ์„ ์‹คํ–‰ํ•˜๋ ค๋Š” ์ด๋ฏธ์ง€์˜ ๊ฒฝ๋กœ์™€ ํ•จ๊ป˜ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

์‚ฌ์šฉ ์ค‘์ธ ๊ฒฝ์šฐ ์ „์šฉ ์ถ”๋ก  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 ๋ฅผ ์ถ”๋ก ์„ ์‹คํ–‰ํ•˜๋ ค๋Š” ์ด๋ฏธ์ง€์˜ ๊ฒฝ๋กœ์™€ ํ•จ๊ป˜ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

์‚ฌ์šฉ ์ค‘์ธ ๊ฒฝ์šฐ ์ „์šฉ ์ถ”๋ก  API์—์„œ url ๋„ ๋งˆ์ฐฌ๊ฐ€์ง€์ž…๋‹ˆ๋‹ค.

์ธ์ˆ˜

์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์ถ”๋ก  ์ธ์ˆ˜์˜ ์ „์ฒด ๋ชฉ๋ก์€ ์•„๋ž˜ ํ‘œ๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.

์ธ์ˆ˜ ๊ธฐ๋ณธ๊ฐ’ ์œ ํ˜• ์„ค๋ช…
file file ์ถ”๋ก ์— ์‚ฌ์šฉํ•  ์ด๋ฏธ์ง€ ๋˜๋Š” ๋™์˜์ƒ ํŒŒ์ผ์ž…๋‹ˆ๋‹ค.
imgsz 640 int ์ž…๋ ฅ ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ, ์œ ํšจํ•œ ๋ฒ”์œ„๋Š” 32 - 1280 ํ”ฝ์…€.
conf 0.25 float ์˜ˆ์ธก์— ๋Œ€ํ•œ ์‹ ๋ขฐ๋„ ์ž„๊ณ„๊ฐ’, ์œ ํšจ ๋ฒ”์œ„ 0.01 - 1.0.
iou 0.45 float ์œ ๋‹ˆ์˜จ ์œ„์˜ ๊ต์ฐจ๋กœ (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": ...
}

์„ธ๋ถ„ํ™”

์„ธ๋ถ„ํ™” ๋ชจ๋ธ

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": ...
}
10๊ฐœ์›” ์ „ ์ƒ์„ฑ๋จ โœ๏ธ 2๊ฐœ์›” ์ „ ์—…๋ฐ์ดํŠธ๋จ

๋Œ“๊ธ€