Code Monkey home page Code Monkey logo

Comments (4)

MaxChanger avatar MaxChanger commented on June 14, 2024

Please provide more information such as how many cards are used for training.

This is a common general error, because adding module.* to the key prefix.

You could try like this:
https://github.com/haomo-ai/MotionSeg3D/blob/dc4c95fcdba2f0819d2bbc4a419f231c55e9c6f3/modules/user.py#L63-L69

self.model = SalsaNextWithMotionAttention(self.parser.get_n_classes(), ARCH, num_batch=self.infer_batch_size)
self.model = nn.DataParallel(self.model)
checkpoint = "SalsaNextWithMotionAttention_refine_module_valid_best"
w_dict = torch.load(f"{self.modeldir}/{checkpoint}", map_location=lambda storage, loc: storage)
# self.model.load_state_dict(w_dict['main_state_dict'], strict=True)
self.model.load_state_dict({f"module.{k}":v for k,v in w_dict['main_state_dict'].items()}, strict=True)

from lidar-mos.

silence-tang avatar silence-tang commented on June 14, 2024

Thanks a lot my friend. It seems like we just need to make a little change to the original code in user.py:
line 64: self.model.load_state_dict(w_dict['state_dict'], strict=Ture) --> self.model.load_state_dict(w_dict['state_dict'], strict=False)
line 70: self.model.load_state_dict(w_dict['state_dict'], strict=Ture) --> self.model.load_state_dict(w_dict['state_dict'], strict=False)
I successfully solved this problem by making changes as shown above, and I hope it may help some other friends who also meet this problem.

from lidar-mos.

MaxChanger avatar MaxChanger commented on June 14, 2024

Hi, @silence-tang, I am very worried that if you use it like this, it will not load successfully.
The logic of strict=False is to load values with equal keys. Although there is no error, it may not load any weight from the checkpoint.
As shown above, I think use this command is better, because strict=False is used directly, other key mismatches cannot be avoided, It is very likely that it did not load any weights from the checkpoint.

# self.model.load_state_dict(w_dict['main_state_dict'], strict=True)
self.model.load_state_dict({f"module.{k}":v for k,v in w_dict['main_state_dict'].items()}, strict=True)

from lidar-mos.

silence-tang avatar silence-tang commented on June 14, 2024

Thank you very much! @MaxChanger I just visualized the .label file generated by my method, but just as you said, it didn't load weight from the checkpoint and every point was labeled 9, which isn't what we expected. After applying the method you proposed, it finally worked in a proper way, thanks!

from lidar-mos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.