aws-samples / host-yolov8-on-sagemaker-endpoint

MIT No Attribution
35 stars 24 forks source link

ModelError when doing inference #12

Closed shenshaoyong closed 3 months ago

shenshaoyong commented 1 year ago

The root cause is that the attribute "keys" of ultralytics.engine.results.Results was changed to "_keys". please refer to https://docs.ultralytics.com/reference/engine/results/#ultralytics.engine.results.Results

So please change the corresponding part of output_fn function in inference.py Below is the my modification:

for result in prediction_output: if 'boxes' in result._keys and result.boxes is not None: infer['boxes'] = result.boxes.numpy().data.tolist() if 'masks' in result._keys and result.masks is not None: infer['masks'] = result.masks.numpy().data.tolist() if 'keypoints' in result._keys and result.keypoints is not None: infer['keypoints'] = result.keypoints.numpy().data.tolist() if 'probs' in result._keys and result.probs is not None: infer['probs'] = result.probs.numpy().data.tolist()

pg-chen commented 10 months ago

I encountered the same error, and then I used the code you modified, it worked! Thanks 😉