コンテンツにスキップ

Ultralytics HUBInference API

モデルをトレーニングした後は、SharedInference API無料で利用することができます。Proユーザーであれば、DedicatedInference APIアクセスできます。Ultralytics HUB Inference API 使用すると、Ultralytics YOLO 環境をローカルにインストールしてセットアップすることなく、REST API 推論を実行できます。

Ultralytics HUBのスクリーンショット。矢印がDedicatedInference API カードとSharedInference API カードを指している。


見る: Ultralytics HUBInference API ウォークスルー

専用Inference API

高い需要と幅広い関心に応えて、私たちはUltralytics HUBDedicatedInference API発表できることを嬉しく思います!

この機能は、パブリックベータ期間中、Pro Planの一部として無料で提供します。将来的には有料プランも検討しています。

  • グローバルカバレッジ: 世界中の38の地域に展開されており、どの場所からでも低遅延アクセスを保証します。Google Cloudリージョンの完全なリストを参照してください
  • Google Cloud Runによるサポート: Google Cloud Runによってサポートされており、無限にスケーラブルで信頼性の高いインフラストラクチャを提供します。
  • 高速: Ultralyticsのテストに基づくと、近隣地域からの640解像度でのYOLOv8n推論では、100ms未満の遅延が可能です。
  • 強化されたセキュリティ: データを保護し、業界標準への準拠を保証するための堅牢なセキュリティ機能を提供します。Google Cloudセキュリティの詳細はこちら

Ultralytics HUBDedicatedInference API使用するには、Start Endpointボタンをクリックします。次に、以下のガイドに記載されている固有のエンドポイントURLを使用します。

Ultralytics HUBのスクリーンショットで、DedicatedInference API カードのStart Endpointボタンを指し示す矢印があるModelページ内のDeployタブ

ヒント

最適なパフォーマンスを得るには、ドキュメントに記載されているように、レイテンシーが最も低いリージョンを選択してください。

専用エンドポイントをシャットダウンするには、Stop Endpointボタンをクリックします。

Ultralytics HUBのスクリーンショットで、DedicatedInference API カードのStop Endpointボタンを指し示す矢印のある、Modelページ内のDeployタブを示している。

共有Inference API

Ultralytics HUB共有Inference API使用するには、以下のガイドに従ってください。

Ultralytics HUB共有Inference API 、以下の使用制限があります:

  • 100 calls / hour

Python

Python使用してUltralytics HUB Inference 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 推論を実行する画像のパスを指定します。

当社の製品をご利用の場合 専用Inference APIは、以下を置き換えます。 url 同様に。

cURL

cURLを使用してUltralytics HUB Inference 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 推論を実行する画像のパスを指定します。

当社の製品をご利用の場合 専用Inference APIは、以下を置き換えます。 url 同様に。

引数

利用可能な推論引数の完全なリストについては、以下の表を参照してください。

引数デフォルト種類説明
filefile推論に使用される画像またはビデオファイル。
imgsz640int入力画像のサイズ、有効範囲は 32 - 1280 ピクセル。
conf0.25float予測の信頼度閾値、有効範囲 0.01 - 1.0.
iou0.45floatIntersection over Union(IoU) (IoU)閾値、有効範囲 0.0 - 0.95.

応答

Ultralytics HUB Inference 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": ...
}


📅 1年前に作成されました✏️ 8か月前に更新されました
glenn-jochersergiuwaxmannMatthewNoycejk4eUltralyticsAssistantRizwanMunawarpriytosh-tripathi

コメント