facebookresearch / detectron2

Detectron2 is a platform for object detection, segmentation and other visual recognition tasks.
https://detectron2.readthedocs.io/en/latest/
Apache License 2.0
30.45k stars 7.47k forks source link

Densepose DensePoseOutputsTextureVisualizer.visualize fails with torch==2.1.0 #5110

Open pjbull opened 1 year ago

pjbull commented 1 year ago

Instructions To Reproduce the 🐛 Bug:

With torch=2.1.0 DensePoseOutputsTextureVisualizer.visualize fails with type mismatch problem.

  1. Full runnable code or full changes you made:
DensePoseOutputsTextureVisualizer().visualize(image_arr, outputs_boxes_xywh_classes)

Result:

TypeError: expected size to be one of int or Tuple[int] or Tuple[int, int] or Tuple[int, int, int], but got size with types [<class 'numpy.int32'>, <class 'numpy.int32'>]

Expected behavior:

No error.

Environment:

This seems to only happen with the latest torch=2.1.0

Cause:

This seems to be caused by the .numpy() call here: https://github.com/facebookresearch/detectron2/blob/main/projects/DensePose/densepose/vis/densepose_outputs_vertex.py#L193

The other visualizer does this with .int() instead, which should fix it: https://github.com/facebookresearch/detectron2/blob/main/projects/DensePose/densepose/vis/densepose_outputs_vertex.py#L80

dsantiago commented 7 months ago

+1

Zakonildo commented 7 months ago

+2