facebookresearch / pytorch3d

PyTorch3D is FAIR's library of reusable components for deep learning with 3D data
https://pytorch3d.org/
Other
8.72k stars 1.31k forks source link

Errors in Rendering #72

Closed shersoni610 closed 4 years ago

shersoni610 commented 4 years ago

Hello,

I installed Python3.6 when things did not work with 3.7 and 3.8. Now I get the following errors:

Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.

Camera position optimization using differentiable rendering In this tutorial we will learn the [x, y, z] position of a camera given a reference image using differentiable rendering.

We will first initialize a renderer with a starting position for the camera. We will then use this to generate an image, compute a loss with the reference image, and finally backpropagate through the entire pipeline to update the position of the camera.

This tutorial shows how to:

load a mesh from an .obj file initialize a Camera, Shader and Renderer, render a mesh set up an optimization loop with a loss function and optimizer Set up and imports import os import torch import numpy as np from tqdm import tqdm_notebook import imageio import torch.nn as nn import torch.nn.functional as F import matplotlib.pyplot as plt from skimage import img_as_ubyte ​

io utils

from pytorch3d.io import load_obj ​

datastructures

from pytorch3d.structures import Meshes, Textures ​

3D transformations functions

from pytorch3d.transforms import Rotate, Translate ​

rendering components

from pytorch3d.renderer import ( OpenGLPerspectiveCameras, look_at_view_transform, look_at_rotation, RasterizationSettings, MeshRenderer, MeshRasterizer, BlendParams, SilhouetteShader, PhongShader, PointLights )

ModuleNotFoundError Traceback (most recent call last)

in 19 20 # rendering components ---> 21 from pytorch3d.renderer import ( 22 OpenGLPerspectiveCameras, look_at_view_transform, look_at_rotation, 23 RasterizationSettings, MeshRenderer, MeshRasterizer, BlendParams, ~/Disk/Software/Anaconda3/envs/pytorch3d/lib/python3.6/site-packages/pytorch3d/renderer/__init__.py in 17 from .lighting import DirectionalLights, PointLights, diffuse, specular 18 from .materials import Materials ---> 19 from .mesh import ( 20 GouradShader, 21 MeshRasterizer, ~/Disk/Software/Anaconda3/envs/pytorch3d/lib/python3.6/site-packages/pytorch3d/renderer/mesh/__init__.py in 2 3 from .rasterize_meshes import rasterize_meshes ----> 4 from .rasterizer import MeshRasterizer, RasterizationSettings 5 from .renderer import MeshRenderer 6 from .shader import ( ~/Disk/Software/Anaconda3/envs/pytorch3d/lib/python3.6/site-packages/pytorch3d/renderer/mesh/rasterizer.py in 3 4 ----> 5 from dataclasses import dataclass 6 from typing import NamedTuple, Optional 7 import torch ModuleNotFoundError: No module named 'dataclasses'
bottler commented 4 years ago

This is a known problem with our release not being compatible with python 3.6. We use a python feature which doesn't exist there. This is fixed in the version on github, and we hope to have a full release soon. For the moment, as a temporary solution, you can try overwriting the file ~/Disk/Software/Anaconda3/envs/pytorch3d/lib/python3.6/site-packages/pytorch3d/renderer/mesh/rasterizer.py with the text at https://raw.githubusercontent.com/facebookresearch/pytorch3d/533887a18885c244d89b292036e167d668736124/pytorch3d/renderer/mesh/rasterizer.py

nikhilaravi commented 4 years ago

Are you running the notebook locally? What was not working with Python 3.7? As mentioned, dataclasses is available in Python 3.7 - see #31 which is about the same issue.

bottler commented 4 years ago

OP's issue in other pythons is in #47. It seems that pytorch itself would not install.

shpotes commented 4 years ago

You can also install dataclasses in python 3.6 and fix the version incompatibility https://pypi.org/project/dataclasses/

nikhilaravi commented 4 years ago

@shersoni610 were you able to resolve this problem? If so, please close this issue.

shersoni610 commented 4 years ago

how can I close it?

On Sun, Feb 23, 2020 at 10:26 PM Nikhila Ravi notifications@github.com wrote:

@shersoni610 https://github.com/shersoni610 were you able to resolve this problem? If so, please close this issue.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebookresearch/pytorch3d/issues/72?email_source=notifications&email_token=ANZR6GWSAPYTXLCELBZJZ3LRENSBXA5CNFSM4KXS47T2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMWXTTA#issuecomment-590182860, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANZR6GS3SRYTHND3BFUFPIDRENSBXANCNFSM4KXS47TQ .