11..
2- .. Copyright 2024-2025 , NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+ .. Copyright 2024-2026 , NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33..
44.. Redistribution and use in source and binary forms, with or without
55.. modification, are permitted provided that the following conditions
@@ -72,13 +72,17 @@ Clone Repository
7272^^^^^^^^^^^^^^^^
7373
7474.. code :: bash
75+
7576 git clone https://github.com/triton-inference-server/tutorials.git
7677 cd tutorials/Triton_Inference_Server_Python_API
78+
7779 Build ``triton-python-api:r24.01 `` Image
7880^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7981
8082.. code :: bash
83+
8184 ./build.sh
85+
8286 Supported Backends
8387^^^^^^^^^^^^^^^^^^
8488
@@ -110,19 +114,25 @@ The following command starts a container and volume mounts the current
110114directory as ``workspace ``.
111115
112116.. code :: bash
117+
113118 ./run.sh
119+
114120 Enter Python Shell
115121~~~~~~~~~~~~~~~~~~
116122
117123.. code :: bash
124+
118125 python3
126+
119127 Create and Start a Server Instance
120128~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121129
122130.. code :: python
131+
123132 import tritonserver
124133 server = tritonserver.Server(model_repository = " /workspace/identity-models" )
125134 server.start()
135+
126136 List Models
127137~~~~~~~~~~~
128138
@@ -137,29 +147,37 @@ Example Output
137147their current state.
138148
139149.. code :: python
150+
140151 {(' identity' , 1 ): {' name' : ' identity' , ' version' : 1 , ' state' : ' READY' }}
152+
141153 Send an Inference Request
142154~~~~~~~~~~~~~~~~~~~~~~~~~
143155
144156.. code :: python
157+
145158 model = server.model(" identity" )
146159 responses = model.infer(inputs = {" string_input" :[[" hello world!" ]]})
160+
147161 Iterate through Responses
148162~~~~~~~~~~~~~~~~~~~~~~~~~
149163
150164``model.infer() `` returns an iterator that can be used to process the
151165results of an inference request.
152166
153167.. code :: python
168+
154169 for response in responses:
155170 print (response.outputs[" string_output" ].to_string_array())
171+
156172 .. _example-output-1 :
157173
158174Example Output
159175^^^^^^^^^^^^^^
160176
161177.. code :: python
178+
162179 [[' hello world!' ]]
180+
163181 Stable Diffusion
164182----------------
165183
@@ -174,7 +192,9 @@ Please note the following command will take many minutes depending on
174192your hardware configuration and network connection.
175193
176194.. code :: bash
177- ./build.sh --framework diffusion --build-models
195+
196+ ./build.sh --framework diffusion --build-models
197+
178198 .. _supported-backends-1 :
179199
180200Supported Backends
@@ -205,25 +225,31 @@ The following command starts a container and volume mounts the current
205225directory as ``workspace ``.
206226
207227.. code :: bash
228+
208229 ./run.sh --framework diffusion
230+
209231 .. _enter-python-shell-1 :
210232
211233Enter Python Shell
212234~~~~~~~~~~~~~~~~~~
213235
214236.. code :: bash
237+
215238 python3
239+
216240 .. _create-and-start-a-server-instance-1 :
217241
218242Create and Start a Server Instance
219243~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
220244
221245.. code :: python
246+
222247 import tritonserver
223248 import numpy
224249 from PIL import Image
225250 server = tritonserver.Server(model_repository = " /workspace/diffusion-models" )
226251 server.start()
252+
227253 .. _list-models-1 :
228254
229255List Models
@@ -239,24 +265,30 @@ Example Output
239265^^^^^^^^^^^^^^
240266
241267.. code :: python
268+
242269 {(' stable_diffusion' , 1 ): {' name' : ' stable_diffusion' , ' version' : 1 , ' state' : ' READY' }, (' text_encoder' , 1 ): {' name' : ' text_encoder' , ' version' : 1 , ' state' : ' READY' }, (' vae' , 1 ): {' name' : ' vae' , ' version' : 1 , ' state' : ' READY' }}
270+
243271 .. _send-an-inference-request-1 :
244272
245273Send an Inference Request
246274~~~~~~~~~~~~~~~~~~~~~~~~~
247275
248276.. code :: python
277+
249278 model = server.model(" stable_diffusion" )
250279 responses = model.infer(inputs = {" prompt" :[[" butterfly in new york, realistic, 4k, photograph" ]]})
280+
251281 Iterate through Responses and save image
252282~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
253283
254284.. code :: python
285+
255286 for response in responses:
256287 generated_image = numpy.from_dlpack(response.outputs[" generated_image" ])
257288 generated_image = generated_image.squeeze().astype(numpy.uint8)
258289 image_ = Image.fromarray(generated_image)
259290 image_.save(" sample_generated_image.jpg" )
291+
260292 .. _example-output-3 :
261293
262294Example Output
0 commit comments