Python SDK と併用する

Python SDK を使用して Roboflow の Serverless Hosted API を利用します。

Pythonで作業している場合、Serverless APIとやり取りする最も便利な方法は、Inference Python SDKを使用することです。

を使用するには、 Inference SDKarrow-up-right、まずそれをインストールします:

pip install inference-sdk

Serverless Hosted APIにリクエストを行うには、次のコードを使用します:

from inference_sdk import InferenceHTTPClient

CLIENT = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key="API_KEY"
)

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

上記で、あなたの model IDarrow-up-rightAPI keyarrow-up-rightを指定してください。 このコードはモデルを実行し、結果を返します。

Roboflow Instant Model

Serverless APIはRoboflowの Instant Modelの実行もサポートしています。Instant Modelは他のモデルと同様に実行できますが、信頼度の閾値がInstant Modelでは敏感になることに注意してください。

circle-info

最適な信頼度は、モデルが学習した画像の数によって異なります。最適な信頼度の閾値は通常0.85から0.99の範囲です。

configuration = InferenceConfiguration(
    confidence_threshold=0.95
)
CLIENT.configure(configuration)

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

Last updated

Was this helpful?