on_model_save callback #5195
Replies: 1 comment
-
@ItayCoifman hello! Thank you for bringing up your thoughts on the The naming might suggest that it's directly tied to the model's weight-saving events, but the current implementation provides a more general epoch-end hook. This design choice allows for flexibility, as users can implement their own logic within the callback to determine when to take specific actions, such as logging to external tools like Weights & Biases. If you're looking to execute actions at specific intervals, like every 20 epochs or when the best model is saved, you could incorporate a conditional check within the We appreciate your feedback and are always looking to improve. If you have suggestions or would like to contribute to enhancing the functionality, please feel free to share your ideas or contribute to the repository. The YOLO community and the Ultralytics team value your input! 🚀 For more detailed information on callbacks and other features, please refer to our documentation at https://docs.ultralytics.com. |
Beta Was this translation helpful? Give feedback.
-
on_model_save callback "sounds" like a callback called when the weights are saved.
The expected behavior (according to its name - at least in my opinion) is that these event callbacks will be called once the model saves weights (best, last, and every save_period epochs).
The actual behavior is that the "saving logic" (best, last, and every save_period epochs) has nothing to do with that callback and this callback is being called every epoch.
if self.args.save or (epoch + 1 == self.epochs): self.save_model() # In this function we can find the "save logic" self.run_callbacks('on_model_save')
I was wondering why it is implemented that way. it seems very straightforward that the callback will be called inside of the save_model() function.
Doing that will enable to use of callbacks easily once every k epochs and not every epoch (for example I want to log to W&B every 20 epochs (or when I get the best model).
Looking forward to hearing your thoughts :)
Beta Was this translation helpful? Give feedback.
All reactions