Reference for ultralytics/utils/triton.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/triton.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.utils.triton.TritonRemoteModel
TritonRemoteModel(url: str, endpoint: str = '', scheme: str = '')
Client for interacting with a remote Triton Inference Server model.
This class provides a convenient interface for sending inference requests to a Triton Inference Server and processing the responses.
Attributes:
Name | Type | Description |
---|---|---|
endpoint |
str
|
The name of the model on the Triton server. |
url |
str
|
The URL of the Triton server. |
triton_client |
The Triton client (either HTTP or gRPC). |
|
InferInput |
The input class for the Triton client. |
|
InferRequestedOutput |
The output request class for the Triton client. |
|
input_formats |
List[str]
|
The data types of the model inputs. |
np_input_formats |
List[type]
|
The numpy data types of the model inputs. |
input_names |
List[str]
|
The names of the model inputs. |
output_names |
List[str]
|
The names of the model outputs. |
metadata |
The metadata associated with the model. |
Methods:
Name | Description |
---|---|
__call__ |
Call the model with the given inputs and return the outputs. |
Examples:
Initialize a Triton client with HTTP
>>> model = TritonRemoteModel(url="localhost:8000", endpoint="yolov8", scheme="http")
Make inference with numpy arrays
>>> outputs = model(np.random.rand(1, 3, 640, 640).astype(np.float32))
Arguments may be provided individually or parsed from a collective 'url' argument of the form
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The URL of the Triton server. |
required |
endpoint
|
str
|
The name of the model on the Triton server. |
''
|
scheme
|
str
|
The communication scheme ('http' or 'grpc'). |
''
|
Examples:
>>> model = TritonRemoteModel(url="localhost:8000", endpoint="yolov8", scheme="http")
>>> model = TritonRemoteModel(url="http://localhost:8000/yolov8")
Source code in ultralytics/utils/triton.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
__call__
__call__(*inputs: ndarray) -> List[np.ndarray]
Call the model with the given inputs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*inputs
|
ndarray
|
Input data to the model. Each array should match the expected shape and type for the corresponding model input. |
()
|
Returns:
Type | Description |
---|---|
List[ndarray]
|
Model outputs with the same dtype as the input. Each element in the list corresponds to one of the model's output tensors. |
Examples:
>>> model = TritonRemoteModel(url="localhost:8000", endpoint="yolov8", scheme="http")
>>> outputs = model(np.random.rand(1, 3, 640, 640).astype(np.float32))
Source code in ultralytics/utils/triton.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|