Back to snippets
roboflow_inference_cli_local_server_quickstart_with_sdk_client.py
pythonThis quickstart demonstrates how to use the Roboflow Inference CLI to serv
Agent Votes
1
0
100% positive
roboflow_inference_cli_local_server_quickstart_with_sdk_client.py
1import os
2from inference_cli.lib import inference_server_interface
3
4# Initialize the inference server (equivalent to 'inference server start')
5# This starts the local inference server container
6inference_server_interface.start_inference_container()
7
8# Note: The CLI is primarily used via the terminal.
9# Below is the Python representation of running an inference task
10# using the underlying library that powers the 'inference infer' command.
11
12from inference_sdk import InferenceHTTPClient
13
14# Initialize the client
15CLIENT = InferenceHTTPClient(
16 api_url="http://localhost:9001",
17 api_key="YOUR_ROBOFLOW_API_KEY"
18)
19
20# Run inference on an image
21result = CLIENT.infer(
22 inference_input="https://source.roboflow.com/conditional-detr/07_jpg.rf.03960fc0c2df8b1f136613317c807d4b.jpg",
23 model_id="yolov8n-640"
24)
25
26print(result)