Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit dde3373

Browse files
authored
[cherry-pick] fixes from release/0.2 testing (#126)
* update postprocessor class for Yolo server example (#124) * bump torch max supported version to 1.7 (#125)
1 parent 27b3f47 commit dde3373

File tree

6 files changed

+11
-9
lines changed

6 files changed

+11
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ clone the repository and install any additional dependencies as required.
312312

313313
The currently supported framework versions are:
314314

315-
- PyTorch supported versions: `>= 1.1.0, < 1.7.0`
315+
- PyTorch supported versions: `>= 1.1.0, < 1.8.0`
316316
- Keras supported versions: `2.3.0-tf` (through the TensorFlow `2.2` package; as of Feb 1st, 2021, `keras2onnx` has
317317
not been tested for TensorFlow >= `2.3`).
318318
- TensorFlow V1 supported versions: >= `1.8.0` (TensorFlow >= `2.X` is not currently supported)

integrations/ultralytics/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ cp ../sparseml/integrations/ultralytics/*.py .
4444
cp ../sparseml/integrations/ultralytics/deepsparse/*.py .
4545

4646
# install dependencies
47+
pip install sparseml[torchvision] deepsparse
4748
pip install -r requirements.txt
48-
pip install sparseml deepsparse
4949
```
5050

5151

@@ -119,7 +119,7 @@ cp sparseml/integrations/ultralytics/deepsparse/*.py yolov5
119119
cd yolov5
120120

121121
# install deepsparse and server dependencies
122-
pip install deepsparse sparseml flask flask-cors
122+
pip install deepsparse sparseml[torchvision] flask flask-cors
123123
```
124124

125125
Note: on new Ubuntu systems, to install `cv2` running `sudo apt-get update && apt-get install -y python3-opencv`

integrations/ultralytics/deepsparse/SERVER.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ cp sparseml/integrations/ultralytics/deepsparse/*.py yolov5
4141
cd yolov5
4242

4343
# install dependencies
44+
pip install deepsparse sparseml[torchvision] flask flask-cors
4445
pip install -r requirements.txt
45-
pip install deepsparse sparseml flask flask-cors
4646
```
4747

4848
## Execution

integrations/ultralytics/deepsparse/deepsparse_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class YoloPostprocessor:
7474
output shapes
7575
"""
7676

77-
def __init__(self, image_size: Tuple[int]):
77+
def __init__(self, image_size: Tuple[int] = (640, 640)):
7878
self._image_size = image_size
7979
self._grids = {} # Dict[Tuple[int], torch.Tensor]
8080

integrations/ultralytics/deepsparse/server.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
import flask
5757
from deepsparse import compile_model
5858
from deepsparse.utils import arrays_to_bytes, bytes_to_arrays
59-
from deepsparse_utils import postprocess_nms, pre_nms_postprocess
59+
from deepsparse_utils import YoloPostprocessor, postprocess_nms
6060
from flask_cors import CORS
6161

6262

@@ -121,6 +121,8 @@ def create_and_run_model_server(
121121
engine = compile_model(model_path, batch_size, num_cores)
122122
print(engine)
123123

124+
postprocessor = YoloPostprocessor()
125+
124126
app = flask.Flask(__name__)
125127
CORS(app)
126128

@@ -145,7 +147,7 @@ def predict():
145147

146148
# post-processing
147149
postprocess_start_time = time.time()
148-
outputs = pre_nms_postprocess(outputs)
150+
outputs = postprocessor.pre_nms_postprocess(outputs)
149151
postprocess_time = time.time() - postprocess_start_time
150152
print(f"Post-processing, pre-nms time: {postprocess_time * 1000.0:.4f}ms")
151153

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
_deepsparse_deps = [
5656
f"{'deepsparse-nightly' if _NIGHTLY else 'deepsparse'}~={_VERSION_MAJOR_MINOR}"
5757
]
58-
_pytorch_deps = ["torch>=1.1.0", "tensorboard>=1.0", "tensorboardX>=1.0"]
59-
_pytorch_vision_deps = _pytorch_deps + ["torchvision>=0.3.0"]
58+
_pytorch_deps = ["torch>=1.1.0,<1.8", "tensorboard>=1.0", "tensorboardX>=1.0"]
59+
_pytorch_vision_deps = _pytorch_deps + ["torchvision>=0.3.0,<0.9"]
6060
_tensorflow_v1_deps = ["tensorflow<2.0.0", "tensorboard<2.0.0", "tf2onnx>=1.0.0,<1.6"]
6161
_tensorflow_v1_gpu_deps = [
6262
"tensorflow-gpu<2.0.0",

0 commit comments

Comments
 (0)