Pytorch3d: [Documentation] DensePose documentation IO error

Created on 14 Mar 2021  路  3Comments  路  Source: facebookresearch/pytorch3d

The code found at the documentation for DensePose rendering contains a bug, caused due to not passing PathManager to _read_image.
I guess this bug introduced 3 month ago, by this commit. It added PathManager as a mandatory input for _read_image function, yet the documentation was not updated accordingly.

The fix is simple as passing an PathManager instance to _read_image. For example:

path_manager = PathManager()
_read_image(file_name=tex_filename, path_manager=path_manager, format='RGB')

And, to add an import from iopath at the modules import section:

from iopath.common.file_io import PathManager

Most helpful comment

Thanks for reporting this. I think it is better to change the tutorial notebook to not use an internal function of PyTorch3D, and I plan to do this.
In particular, I would replace

tex = torch.from_numpy(_read_image(file_name=tex_filename, format='RGB') / 255. ).unsqueeze(0).to(device)

with

with Image.open(tex_filename) as image:
    np_image = np.asarray(image.convert("RGB")).astype(np.float32)
tex = torch.from_numpy(np_image / 255. )[None].to(device)

and replace the import of _read_image with from PIL import Image.

All 3 comments

Thanks for reporting this. I think it is better to change the tutorial notebook to not use an internal function of PyTorch3D, and I plan to do this.
In particular, I would replace

tex = torch.from_numpy(_read_image(file_name=tex_filename, format='RGB') / 255. ).unsqueeze(0).to(device)

with

with Image.open(tex_filename) as image:
    np_image = np.asarray(image.convert("RGB")).astype(np.float32)
tex = torch.from_numpy(np_image / 255. )[None].to(device)

and replace the import of _read_image with from PIL import Image.

Thanks for reporting this @OmriKaduri!

This is now fixed in 6c4151a.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abhi1kumar picture abhi1kumar  路  3Comments

NotAnyMike picture NotAnyMike  路  3Comments

florianHofherr picture florianHofherr  路  3Comments

shersoni610 picture shersoni610  路  3Comments

zhjscut picture zhjscut  路  3Comments