Model Serving
モデルサービングがどのように学習済みモデルと本番環境の架け橋となるかを学びます。Ultralytics Platform 上での Ultralytics YOLO26 のデプロイ戦略を探りましょう。
モデルサービングとは、トレーニング済みの機械学習モデルをホスティングし、ネットワークインターフェースを通じてソフトウェアアプリケーションからその機能を利用できるようにするプロセスです。ディスクに保存された静的なモデルファイルと、実世界のデータを処理するライブシステムとの間の橋渡し役を果たします。モデルの機械学習 (ML)のトレーニングフェーズが完了したら、モデルを本番環境に統合する必要があります。そこでモデルは画像、テキスト、表データなどの入力を受け取り、予測を返すことが可能になります。これは通常、モデルをApplication Programming Interface (API)でラップすることで実現され、Webサーバー、モバイルアプリ、IoTデバイスとの通信が可能になります。
Link to this sectionAIにおけるモデルサービングの役割#
The primary goal of model serving is to operationalize predictive modeling capabilities effectively. While training focuses on accuracy and loss minimization, serving focuses on performance metrics like latency (how fast a prediction is returned) and throughput (how many requests can be handled per second). Robust serving infrastructure ensures that computer vision (CV) systems remain reliable under heavy loads. It often involves technologies like containerization using tools such as Docker, which packages the model with its dependencies to ensure consistent behavior across different computing environments.
Link to this section実社会での応用#
モデルサービングは、データに基づいた即時の意思決定を可能にすることで、さまざまな業界に広がるAI機能を支えています。
- スマートマニュファクチャリング: 産業環境において、製造業におけるAIシステムは、提供されたモデルを使用して組立ラインを検査します。コンポーネントの高解像度画像がローカルサーバーに送信され、そこでYOLO26モデルが傷や位置ずれなどの欠陥を検出し、不良品を取り除くための即時アラートをトリガーします。
- 小売オートメーション: 小売業者は小売業におけるAIを活用して顧客体験を向上させています。物体検出モデルによって稼働するカメラが、チェックアウトゾーンで製品を識別し、手動でバーコードをスキャンすることなく合計金額を自動的に算出します。
Link to this section実践的な実装#
To serve a model effectively, it is often beneficial to export models to a standardized format like ONNX, which promotes interoperability between different training frameworks and serving engines. The following example demonstrates how to load a model and run inference, simulating the logic that would exist inside a serving endpoint using Python.
from ultralytics import YOLO
# Load the YOLO26 model (this typically happens once when the server starts)
model = YOLO("yolo26n.pt")
# Simulate an incoming API request with an image source URL
image_source = "https://ultralytics.com/images/bus.jpg"
# Run inference to generate predictions for the user
results = model.predict(source=image_source)
# Process results (e.g., simulating a JSON response to a client)
print(f"Detected {len(results[0].boxes)} objects in the image.")Link to this section適切な戦略の選択#
サービング戦略の選択は、特定のユースケースに大きく依存します。オンラインサービングはRESTやgRPCといったプロトコルを通じて即時の応答を提供し、ユーザー向けのWebアプリケーションに不可欠です。一方、バッチサービングは夜間のレポート生成などのタスクに適しており、大量のデータをオフラインで処理します。プライバシー保護やインターネットに依存しない低レイテンシが必要なアプリケーションの場合、Edge AIがサービングプロセスをデバイスに直接移動させ、TensorRTのような最適化された形式を利用して制約のあるハードウェア上でパフォーマンスを最大化します。多くの組織がUltralytics Platformを活用し、クラウドAPIやエッジデバイスを含む様々なエンドポイントへのモデルデプロイを簡素化しています。
Link to this section関連用語との違い#
密接に関連していますが、「モデルサービング」はモデルデプロイや推論とは異なります。
- モデルデプロイ: これは、モデルを本番環境にリリースするという、より広いライフサイクルステージを指します。サービングは、デプロイされたモデルを実行するために使用される具体的なメカニズムやソフトウェア(NVIDIA Triton Inference ServerやTorchServeなど)のことです。
- Inference: This is the mathematical act of calculating a prediction from an input. Model serving provides the infrastructure (networking, scalability, and security) that allows inference to happen reliably for end-users.
- マイクロサービス: サービングは多くの場合、マイクロサービスの集合として設計されます。ここではモデルが独立したサービスとして実行され、アプリケーションの他の部分がクエリを実行し、多くの場合JSONなどの軽量な形式でデータを交換します。






