Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'Textures' #64

Closed
ak9250 opened this issue Sep 9, 2020 · 16 comments
Closed

ImportError: cannot import name 'Textures' #64

ak9250 opened this issue Sep 9, 2020 · 16 comments

Comments

@ak9250
Copy link

ak9250 commented Sep 9, 2020

ImportError Traceback (most recent call last)
in ()
----> 1 from lib.colab_util import generate_video_from_obj, set_renderer, video
2
3 renderer = set_renderer()
4 generate_video_from_obj(obj_path, out_img_path, video_path, renderer)
5

/content/pifuhd/lib/colab_util.py in ()
39
40 # Data structures and functions for rendering
---> 41 from pytorch3d.structures import Meshes, Textures
42 from pytorch3d.renderer import (
43 look_at_view_transform,

ImportError: cannot import name 'Textures'

from the google colab could be due to pytorch3d version?

@shunsukesaito
Copy link
Contributor

The same issue was raised in PIFu repository and the pull request is merged there. Unfortunately I don't have bandwidth to change the code in PIFuHD for now. But you can make the same modification in pifuhd repo as well. Thanks.
shunsukesaito/PIFu#66

@suyashcjoshi
Copy link

I'm seeing same error, very annoying.

@suyashcjoshi
Copy link

The same issue was raised in PIFu repository and the pull request is merged there. Unfortunately I don't have bandwidth to change the code in PIFuHD for now. But you can make the same modification in pifuhd repo as well. Thanks.
shunsukesaito/PIFu#66

after making the suggested change, still getting another error:

/content/pifuhd/lib/colab_util.py in <module>()
     41 from pytorch3d.renderer import TexturesVertex
     42 from pytorch3d.structures import Meshes
---> 43 from pytorch3d.renderer import (
     44     look_at_view_transform,
     45     OpenGLOrthographicCameras,

ImportError: cannot import name 'TexturedSoftPhongShader'

@hfarhidzadeh
Copy link

hfarhidzadeh commented Sep 11, 2020

Facing same issue :/

I don't see any documentation under https://pytorch3d.readthedocs.io/en/latest/modules/renderer/texturing.html. I guess the moved texturing from structures to render class.

@WozLai
Copy link

WozLai commented Sep 15, 2020

Same issue
PyTorch3D is updated to v 0.2.5 (https://github.com/facebookresearch/pytorch3d/releases)
Now, from pytorch3d.structures import Textures -->
from pytorch3d.renderer import TexturesUV, TexturesVertex, TexturesAtlas

Line 42
from pytorch3d.renderer import ( look_at_view_transform, OpenGLOrthographicCameras, PointLights, DirectionalLights, Materials, RasterizationSettings, MeshRenderer, MeshRasterizer, TexturedSoftPhongShader, HardPhongShader )
to
from pytorch3d.renderer import ( look_at_view_transform, OpenGLOrthographicCameras, PointLights, DirectionalLights, Materials, RasterizationSettings, MeshRenderer, MeshRasterizer, SoftPhongShader, HardPhongShader, TexturesUV, TexturesVertex, TexturesAtlas )

Line 111
textures = Textures(verts_rgb=verts_rgb_colors) wo_textures = Textures(verts_rgb=torch.ones_like(verts_rgb_colors)*0.75)
to
textures = TexturesVertex(verts_rgb=verts_rgb_colors) wo_textures = TexturesVertex(verts_rgb=torch.ones_like(verts_rgb_colors)*0.75)

After that,it work :)

@farazBhatti
Copy link

@GambleV after applying chagnges you recommended above, I am getting the following error.

    114     verts_rgb_colors = get_verts_rgb_colors(obj_path)
    115     verts_rgb_colors = torch.from_numpy(verts_rgb_colors).to(device)
--> 116     textures = TexturesVertex(verts_rgb=verts_rgb_colors)
    117     wo_textures = TexturesVertex(verts_rgb=torch.ones_like(verts_rgb_colors)*0.75)
    118 

TypeError: __init__() got an unexpected keyword argument 'verts_rgb'

Any help? Thanks

@WozLai
Copy link

WozLai commented Sep 16, 2020

@farazBhatti , apologize for post wrong ans. The two lines should be changed to
textures = TexturesVertex(verts_features=verts_rgb_colors)
wo_textures = TexturesVertex(verts_features=torch.ones_like(verts_rgb_colors)*0.75)

Try this :)

@wanfuse123
Copy link

where in the google colab do I put this?

Thanks!!!

@wanfuse123
Copy link

Also, Do you have detailed instructions for running this locally? Or in a docker VM (with and without nvidai-cuda support?)

@WozLai
Copy link

WozLai commented Sep 16, 2020

@wanfuse123
git+url ?
I just test it in google colab for PIFuHD example.

@wanfuse123
Copy link

What FILE is this change supposed to be made in ? I downloaded the project , installed all its dependencies, and I get the error. Can you tell me what file these lines are changed in.

grep -R "from pytorch3d.renderer import" . turns up nothing in the pifudh directory.

Thanks for being patient!

@EnricoBeltramo
Copy link

for me error at:

NameError Traceback (most recent call last)
in ()
2
3 renderer = set_renderer()
----> 4 generate_video_from_obj(obj_path, out_img_path, video_path, renderer)
5
6 # we cannot play a mp4 video generated by cv2

/content/pifuhd/lib/colab_util.py in generate_video_from_obj(obj_path, image_path, video_path, renderer)
106 f rom pytorch3d.renderer import Meshes
107 vers = mesh._verts_list
--> 108 faces = mesh._faces_list
109 mesh_w_tex = Meshes(vers, faces, textures)
110 mesh_wo_tex = Meshes(vers, faces, wo_textures)

NameError: name 'Meshes' is not defined

@WozLai
Copy link

WozLai commented Sep 17, 2020

@EnricoBeltramo
Line 106
Try from pytorch3d.structures import Meshes

@WozLai
Copy link

WozLai commented Sep 17, 2020

This issue occur in lib/colab_util.py when use from pytorch3d.structures import Textures. But new version Textures is deprecated.

@EnricoBeltramo
Copy link

@EnricoBeltramo
Line 106
Try from pytorch3d.structures import Meshes

I suppose meshes doesn't exist anymore in pytorch3d:

---> 41 from pytorch3d.renderer import TexturesUV, TexturesVertex, TexturesAtlas, Meshes
42 from pytorch3d.renderer import ( look_at_view_transform, OpenGLOrthographicCameras, PointLights, DirectionalLights, Materials, RasterizationSettings, MeshRenderer, MeshRasterizer, SoftPhongShader, HardPhongShader, TexturesUV, TexturesVertex, TexturesAtlas )
43

ImportError: cannot import name 'Meshes'

Some one know the correct version of pytorch3d in order to change colab here:
!pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'
and align to version of pytorch3d the SW was tested with?

@shunsukesaito
Copy link
Contributor

Sorry for having you guys wait for long time. I just made fix and it should be working now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants