Giter VIP home page Giter VIP logo

Comments (3)

glenn-jocher avatar glenn-jocher commented on June 25, 2024

Hello! It looks like you're trying to train a new network structure using pre-existing weights. If your model reverts to the original structure during training, it might be due to the way the weights are being loaded. Ensure that the weights are compatible with the new model structure, and check if the model definition in your training script correctly reflects the new architecture.

Here's a quick example of how you can load the weights:

from ultralytics import YOLO

# Load your custom model architecture
model = YOLO('path/to/new_model.yaml')

# Load weights from the old model
model.load('path/to/old_weights.pt', strict=False)  # Use strict=False to allow mismatch

# Now you can proceed with training
model.train('data.yaml', epochs=100)

Make sure that the strict=False parameter is used to allow for the size mismatches between the new model and the old weights. This should help in adapting the old weights to your new structure without forcing the architecture to revert. If you continue to experience issues, double-check the architecture changes and ensure they are saved correctly.

from ultralytics.

TonightGo avatar TonightGo commented on June 25, 2024

load() got an unexpected keyword argument 'strict',but in the function, it set strict=False default when call torch.load.
I use model.load('path/to/old_weights.pt'), it works.
Thank you for your help. ~~

from ultralytics.

glenn-jocher avatar glenn-jocher commented on June 25, 2024

@TonightGo hello! I'm glad to hear that using model.load('path/to/old_weights.pt') worked out for you. It seems there was a misunderstanding regarding the strict parameter; it's not directly used in the model.load() method for YOLOv8. The method handles the loading process internally, including any necessary adjustments for weight compatibility. If you have any more questions or need further assistance, feel free to ask. Happy coding! 😊

from ultralytics.

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.