magicleap / Atlas

Atlas: End-to-End 3D Scene Reconstruction from Posed Images
Apache License 2.0
1.82k stars 223 forks source link

model weights are not loaded #45

Open kn-ru opened 3 years ago

kn-ru commented 3 years ago

Good day. Model weights are not loaded.

import os

import numpy as np
import torch

from atlas.data import SceneDataset, parse_splits_list
from atlas.model import VoxelNet
import atlas.transforms as transforms
model = VoxelNet
model.load_from_checkpoint(checkpoint_path='final.ckpt')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-6-89c83cb76361> in <module>()
----> 1 model.load_from_checkpoint(checkpoint_path='final.ckpt')

/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/pytorch_lightning/core/saving.py in load_from_checkpoint(cls, checkpoint_path, map_location, hparams_file, strict, **kwargs)
    155         checkpoint[cls.CHECKPOINT_HYPER_PARAMS_KEY].update(kwargs)
    156 
--> 157         model = cls._load_model_state(checkpoint, strict=strict, **kwargs)
    158         return model
    159 

/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/pytorch_lightning/core/saving.py in _load_model_state(cls, checkpoint, strict, **cls_kwargs_new)
    197             _cls_kwargs = {k: v for k, v in _cls_kwargs.items() if k in cls_init_args_name}
    198 
--> 199         model = cls(**_cls_kwargs)
    200 
    201         # give model a chance to load something

/home/ubuntu/kot/Atlas/atlas/model.py in __init__(self, hparams)
     91 
     92         # see config.py for details
---> 93         self.hparams = hparams
     94 
     95         # pytorch lightning does not support saving YACS CfgNone

/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/nn/modules/module.py in __setattr__(self, name, value)
    636                     buffers[name] = value
    637                 else:
--> 638                     object.__setattr__(self, name, value)
    639 
    640     def __delattr__(self, name):

AttributeError: can't set attribute

You can tell what could be wrong. I use the environment as required.

kn-ru commented 3 years ago

In Colab notebook exactly the same

dephaniehe commented 3 years ago

It's either a typo (self.hparams should be self._hparams in the initialization function) or the authors forgot to implement the setter function for the self.hparams property (in which the property itself is defined in the parent class, but the setter function needs to be defined the each sub-class)

Tetsujinfr commented 3 years ago

Getting the same issue, after spending hours to prep the environment...

@zmurez-ml , any idea on how to sort this out?

tks

Tetsujinfr commented 3 years ago

So in model.py, line 93, replacing self.hparams = hparams by self._hparams = hparams, it fixes the issue. Thanks @dephaniehe.

Attaching an inference with voxel size of 224 x 224 x 64 (do not have enough RAM for more). Quality is ok, although a stereo camera with a good SLAM algo does a better job I think. Would love to have the textures, need to look at that now.

sample1_224_224_64

HaFred commented 3 years ago

So in model.py, line 93, replacing self.hparams = hparams by self._hparams = hparams, it fixes the issue. Thanks @dephaniehe.

Attaching an inference with voxel size of 224 x 224 x 64 (do not have enough RAM for more). Quality is ok, although a stereo camera with a good SLAM algo does a better job I think. Would love to have the textures, need to look at that now.

sample1_224_224_64

Hi @Tetsujinfr , sorry to bother. May I know which visualization app u are using? I tried cloudcompare and meshlab but the inference results as in the readme seems not ok for these two.

Tetsujinfr commented 3 years ago

From memory I think I have used this online viewer. I just checked and it works with the .ply generated on my side (no texture).

xuyanging commented 3 years ago

Hi,I can run inference.py and output three files (samples1.npz, sample1.ply, sample1_attributes.npz ) with your provided data. I want to visulize sample1.ply so I use colmap, but it get error. could you give me some suggestions about how to visulize the results from model output?