fix error when detection output is null (#351) · alibaba/EasyCV@901ff18

File tree

1 file changed

lines changed

  • easycv/toolkit/modelscope/pipelines

1 file changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -48,9 +48,15 @@ def __call__(self, inputs) -> Any:

4848

labels = []

4949

boxes = []

5050

for output in outputs:

51-

for score, label, box in zip(output['detection_scores'],

52-

output['detection_classes'],

53-

output['detection_boxes']):

51+

scores_list = output['detection_scores'] if output[

52+

'detection_scores'] is not None else []

53+

classes_list = output['detection_classes'] if output[

54+

'detection_classes'] is not None else []

55+

boxes_list = output['detection_boxes'] if output[

56+

'detection_boxes'] is not None else []

57+
58+

for score, label, box in zip(scores_list, classes_list,

59+

boxes_list):

5460

scores.append(score)

5561

labels.append(self.cfg.CLASSES[label])

5662

boxes.append([b for b in box])