Skip to content

Commit 5a2b1bf

Browse files
committed
fix lint
1 parent 2c7d054 commit 5a2b1bf

File tree

33 files changed

+231
-179
lines changed

33 files changed

+231
-179
lines changed

csrc/mmdeploy/triton/instance_state.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ TRITONSERVER_Error* ModelInstanceState::Execute(TRITONBACKEND_Request** requests
247247
}
248248
}
249249

250-
// merget inputs for example: [[a,a,a], [b,b,b], [c,c,c]] -> [[aaa], [(b,c), (b,c), (b,c)]]
250+
// merge inputs for example: [[a,a,a], [b,b,b], [c,c,c]] -> [[aaa], [(b,c), (b,c), (b,c)]]
251251
if (!merge_inputs_.empty()) {
252252
int n_example = vec_inputs[0].size();
253253
::mmdeploy::Value inputs;

demo/triton/image-classification/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Image classification serving
22

3-
43
## Starting a docker container
4+
55
```
66
docker run -it --rm --gpus all openmmlab/mmdeploy:triton-22.12
77
```
88

99
## Convert pytorch model to tensorrt model
10+
1011
```
1112
cd /root/workspace/mmdeploy
1213
python3 tools/deploy.py \
@@ -20,6 +21,7 @@ python3 tools/deploy.py \
2021
```
2122

2223
## Convert tensorrt model to triton format
24+
2325
```
2426
cd /root/workspace/mmdeploy
2527
python3 demo/triton/to_triton_model.py \
@@ -28,11 +30,13 @@ python3 demo/triton/to_triton_model.py \
2830
```
2931

3032
## Start triton server
33+
3134
```
3235
tritonserver --model-repository=/model-repository
3336
```
3437

3538
## Run client code output container
39+
3640
```
3741
python3 demo/triton/image-classification/grpc_client.py \
3842
model \

demo/triton/image-classification/grpc_client.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Copyright (c) OpenMMLab. All rights reserved.
22
import argparse
3+
34
import cv2
4-
from tritonclient.grpc import InferenceServerClient, InferInput, InferRequestedOutput
5+
from tritonclient.grpc import (InferenceServerClient, InferInput,
6+
InferRequestedOutput)
57

68

79
def parse_args():
810
parser = argparse.ArgumentParser()
9-
parser.add_argument('model_name', type=str,
10-
help='model name')
11-
parser.add_argument('image', type=str,
12-
help='image path')
11+
parser.add_argument('model_name', type=str, help='model name')
12+
parser.add_argument('image', type=str, help='image path')
1313
return parser.parse_args()
1414

1515

@@ -22,14 +22,16 @@ def __init__(self, url, model_name, model_version):
2222
self._client = InferenceServerClient(self._url)
2323
model_config = self._client.get_model_config(self._model_name,
2424
self._model_version)
25-
model_metadata = self._client.get_model_metadata(self._model_name,
26-
self._model_version)
25+
model_metadata = self._client.get_model_metadata(
26+
self._model_name, self._model_version)
2727
print(f'[model config]:\n{model_config}')
2828
print(f'[model metadata]:\n{model_metadata}')
2929
self._inputs = {input.name: input for input in model_metadata.inputs}
3030
self._input_names = list(self._inputs)
3131
self._outputs = {
32-
output.name: output for output in model_metadata.outputs}
32+
output.name: output
33+
for output in model_metadata.outputs
34+
}
3335
self._output_names = list(self._outputs)
3436
self._outputs_req = [
3537
InferRequestedOutput(name) for name in self._outputs
@@ -43,8 +45,7 @@ def infer(self, image):
4345
results: dict, {name : numpy.array}
4446
"""
4547

46-
inputs = [InferInput(self._input_names[0], image.shape,
47-
"UINT8")]
48+
inputs = [InferInput(self._input_names[0], image.shape, 'UINT8')]
4849
inputs[0].set_data_from_numpy(image)
4950
results = self._client.infer(
5051
model_name=self._model_name,
@@ -65,11 +66,11 @@ def visualize(results):
6566
print(f'label {labels[i]} score {scores[i]}')
6667

6768

68-
if __name__ == "__main__":
69+
if __name__ == '__main__':
6970
args = parse_args()
7071
model_name = args.model_name
71-
model_version = "1"
72-
url = "localhost:8001"
72+
model_version = '1'
73+
url = 'localhost:8001'
7374
client = GRPCTritonClient(url, model_name, model_version)
7475
img = cv2.imread(args.image)
7576
results = client.infer(img)
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
This directory holds the model files.
1+
This directory holds the model files.

demo/triton/instance-segmentation/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Instance segmentation serving
22

3-
43
## Starting a docker container
4+
55
```
66
docker run -it --rm --gpus all openmmlab/mmdeploy:triton-22.12
77
```
88

99
## Convert pytorch model to tensorrt model
10+
1011
```
1112
cd /root/workspace/mmdeploy
1213
python3 tools/deploy.py \
@@ -20,6 +21,7 @@ python3 tools/deploy.py \
2021
```
2122

2223
## Convert tensorrt model to triton format
24+
2325
```
2426
cd /root/workspace/mmdeploy
2527
python3 demo/triton/to_triton_model.py \
@@ -28,11 +30,13 @@ python3 demo/triton/to_triton_model.py \
2830
```
2931

3032
## Start triton server
33+
3134
```
3235
tritonserver --model-repository=/model-repository
3336
```
3437

3538
## Run client code output container
39+
3640
```
3741
python3 demo/triton/instance-segmentation/grpc_client.py \
3842
model \

demo/triton/instance-segmentation/grpc_client.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Copyright (c) OpenMMLab. All rights reserved.
22
import argparse
3-
import cv2
4-
from tritonclient.grpc import InferenceServerClient, InferInput, InferRequestedOutput
53
import math
64

5+
import cv2
6+
from tritonclient.grpc import (InferenceServerClient, InferInput,
7+
InferRequestedOutput)
8+
79

810
def parse_args():
911
parser = argparse.ArgumentParser()
10-
parser.add_argument('model_name', type=str,
11-
help='model name')
12-
parser.add_argument('image', type=str,
13-
help='image path')
12+
parser.add_argument('model_name', type=str, help='model name')
13+
parser.add_argument('image', type=str, help='image path')
1414
return parser.parse_args()
1515

1616

@@ -23,14 +23,16 @@ def __init__(self, url, model_name, model_version):
2323
self._client = InferenceServerClient(self._url)
2424
model_config = self._client.get_model_config(self._model_name,
2525
self._model_version)
26-
model_metadata = self._client.get_model_metadata(self._model_name,
27-
self._model_version)
26+
model_metadata = self._client.get_model_metadata(
27+
self._model_name, self._model_version)
2828
print(f'[model config]:\n{model_config}')
2929
print(f'[model metadata]:\n{model_metadata}')
3030
self._inputs = {input.name: input for input in model_metadata.inputs}
3131
self._input_names = list(self._inputs)
3232
self._outputs = {
33-
output.name: output for output in model_metadata.outputs}
33+
output.name: output
34+
for output in model_metadata.outputs
35+
}
3436
self._output_names = list(self._outputs)
3537
self._outputs_req = [
3638
InferRequestedOutput(name) for name in self._outputs
@@ -44,8 +46,7 @@ def infer(self, image):
4446
results: dict, {name : numpy.array}
4547
"""
4648

47-
inputs = [InferInput(self._input_names[0], image.shape,
48-
"UINT8")]
49+
inputs = [InferInput(self._input_names[0], image.shape, 'UINT8')]
4950
inputs[0].set_data_from_numpy(image)
5051
results = self._client.infer(
5152
model_name=self._model_name,
@@ -83,11 +84,11 @@ def visualize(img, results):
8384
cv2.imwrite('instance-segmentation.jpg', img)
8485

8586

86-
if __name__ == "__main__":
87+
if __name__ == '__main__':
8788
args = parse_args()
8889
model_name = args.model_name
89-
model_version = "1"
90-
url = "localhost:8001"
90+
model_version = '1'
91+
url = 'localhost:8001'
9192
client = GRPCTritonClient(url, model_name, model_version)
9293
img = cv2.imread(args.image)
9394
results = client.infer(img)
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
This directory holds the model files.
1+
This directory holds the model files.

demo/triton/instance-segmentation/serving/model/config.pbtxt

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ output {
2727
name: "mask_offs"
2828
data_type: TYPE_INT32
2929
dims: [ -1, 3 ]
30-
}
30+
}

demo/triton/keypoint-detection/README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Keypoint detection serving
22

33
## Starting a docker container
4+
45
```
56
docker run -it --rm --gpus all openmmlab/mmdeploy:triton-22.12
67
```
78

89
## Convert pytorch model to tensorrt model
10+
911
```
1012
cd /root/workspace/mmdeploy
1113
python3 tools/deploy.py \
@@ -19,6 +21,7 @@ python3 tools/deploy.py \
1921
```
2022

2123
## Convert tensorrt model to triton format
24+
2225
```
2326
cd /root/workspace/mmdeploy
2427
python3 demo/triton/to_triton_model.py \
@@ -27,13 +30,15 @@ python3 demo/triton/to_triton_model.py \
2730
```
2831

2932
## Start triton server
33+
3034
```
3135
tritonserver --model-repository=/model-repository
3236
```
3337

3438
## Run client code output container
39+
3540
```
3641
python3 demo/triton/keypoint-detection/grpc_client.py \
3742
model \
3843
/path/to/image
39-
```
44+
```

demo/triton/keypoint-detection/grpc_client.py

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Copyright (c) OpenMMLab. All rights reserved.
22
import argparse
3+
import json
4+
35
import cv2
4-
from tritonclient.grpc import InferenceServerClient, InferInput, InferRequestedOutput
56
import numpy as np
6-
import json
7+
from tritonclient.grpc import (InferenceServerClient, InferInput,
8+
InferRequestedOutput)
79

810

911
def parse_args():
1012
parser = argparse.ArgumentParser()
11-
parser.add_argument('model_name', type=str,
12-
help='model name')
13-
parser.add_argument('image', type=str,
14-
help='image path')
13+
parser.add_argument('model_name', type=str, help='model name')
14+
parser.add_argument('image', type=str, help='image path')
1515
return parser.parse_args()
1616

1717

@@ -24,14 +24,16 @@ def __init__(self, url, model_name, model_version):
2424
self._client = InferenceServerClient(self._url)
2525
model_config = self._client.get_model_config(self._model_name,
2626
self._model_version)
27-
model_metadata = self._client.get_model_metadata(self._model_name,
28-
self._model_version)
27+
model_metadata = self._client.get_model_metadata(
28+
self._model_name, self._model_version)
2929
print(f'[model config]:\n{model_config}')
3030
print(f'[model metadata]:\n{model_metadata}')
3131
self._inputs = {input.name: input for input in model_metadata.inputs}
3232
self._input_names = list(self._inputs)
3333
self._outputs = {
34-
output.name: output for output in model_metadata.outputs}
34+
output.name: output
35+
for output in model_metadata.outputs
36+
}
3537
self._output_names = list(self._outputs)
3638
self._outputs_req = [
3739
InferRequestedOutput(name) for name in self._outputs
@@ -46,10 +48,10 @@ def infer(self, image, box):
4648
results: dict, {name : numpy.array}
4749
"""
4850

49-
inputs = [InferInput(self._input_names[0], image.shape,
50-
"UINT8"),
51-
InferInput(self._input_names[1], box.shape,
52-
"BYTES")]
51+
inputs = [
52+
InferInput(self._input_names[0], image.shape, 'UINT8'),
53+
InferInput(self._input_names[1], box.shape, 'BYTES')
54+
]
5355
inputs[0].set_data_from_numpy(image)
5456
inputs[1].set_data_from_numpy(box)
5557
results = self._client.infer(
@@ -72,20 +74,18 @@ def visualize(img, results):
7274
cv2.imwrite('keypoint-detection.jpg', img)
7375

7476

75-
if __name__ == "__main__":
77+
if __name__ == '__main__':
7678
args = parse_args()
7779
model_name = args.model_name
78-
model_version = "1"
79-
url = "localhost:8001"
80+
model_version = '1'
81+
url = 'localhost:8001'
8082
client = GRPCTritonClient(url, model_name, model_version)
8183
img = cv2.imread(args.image)
8284
bbox = {
8385
'type': 'PoseBbox',
84-
'value': [
85-
{
86-
'bbox': [0.0, 0.0, img.shape[1], img.shape[0]]
87-
}
88-
]
86+
'value': [{
87+
'bbox': [0.0, 0.0, img.shape[1], img.shape[0]]
88+
}]
8989
}
9090
bbox = np.array([json.dumps(bbox).encode('utf-8')])
9191
results = client.infer(img, bbox)
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
This directory holds the model files.
1+
This directory holds the model files.

demo/triton/keypoint-detection/serving/model/config.pbtxt

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ parameters {
2626
value: {
2727
string_value: "0 1"
2828
}
29-
}
29+
}

0 commit comments

Comments
 (0)