cc icon indicating copy to clipboard operation
cc copied to clipboard

the output images' format should be changed from CHW to HWC

Open nightmaredimple opened this issue 5 years ago • 8 comments

Tensors in pytorch are formatted in CHW(BCHW) by default, so if you wanna output the results of depth,flow and mask, you should change them into HWC format. such as: test_flow.py line 180

row1_viz_im = Image.fromarray((255*row1_viz).astype('uint8')) row2_viz_im = Image.fromarray((row2_viz).astype('uint8'))

this will raise TypeError("Cannot handle this data type") you should transpose/permute the format into HWC like this below:

row1_viz_im = Image.fromarray((255*row1_viz).astype('uint8').transpose((1,2,0))) row2_viz_im = Image.fromarray((row2_viz).astype('uint8').transpose((1,2,0)))

nightmaredimple avatar Jun 13 '19 20:06 nightmaredimple

Due to the problem above, when testing masks' output, the results of flow are totally black. Besides, the colormap of hot needs to be defined in utils/COLORMAPS.

nightmaredimple avatar Jun 13 '19 21:06 nightmaredimple

okay. this is due to version changes in torchvision. Can you send a pull request for the fix? Thanks so much.

anuragranj avatar Jun 18 '19 06:06 anuragranj

I'm getting rid of some features in old versions of pytorch . so maybe a few days later~

nightmaredimple avatar Jun 18 '19 08:06 nightmaredimple

Okay. Thank you so much :)

anuragranj avatar Jun 18 '19 12:06 anuragranj

Due to the problem above, when testing masks' output, the results of flow are totally black. Besides, the colormap of hot needs to be defined in utils/COLORMAPS.

Do you know how to define the colormap of hot in utils/COLORMAPS please?

ChenjieWang avatar Aug 31 '19 11:08 ChenjieWang

hot can be found here: https://matplotlib.org/3.1.1/gallery/color/colormap_reference.html and can be used by modifying this line: https://github.com/anuragranj/cc/blob/master/utils.py#L34

anuragranj avatar Sep 05 '19 13:09 anuragranj

I have the same problem with you. Do you solve the problem correctly and how to modify the code in 'test_mask.py' and 'utils.py'?

viz3_im = Image.fromarray(viz3.astype('uint8')) TypeError: Cannot handle this data type

Thank you (^_^) @anuragranj @ChenjieWang

swrdZWJ avatar Sep 11 '19 07:09 swrdZWJ

Due to the problem above, when testing masks' output, the results of flow are totally black. Besides, the colormap of hot needs to be defined in utils/COLORMAPS.

I wonder how to solve the black problem. Thanks a lot~

lotus0903 avatar Sep 09 '22 01:09 lotus0903