Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📚 v1 - Docs Add the feature to resume training from a previous training #1558

Closed
shrinand1996 opened this issue Dec 20, 2023 · 8 comments · Fixed by #2389
Closed

📚 v1 - Docs Add the feature to resume training from a previous training #1558

shrinand1996 opened this issue Dec 20, 2023 · 8 comments · Fixed by #2389
Assignees
Labels
Documentation Improvements or additions to documentation
Milestone

Comments

@shrinand1996
Copy link

What is the motivation for this task?

It will be great if we can resume training (for EfficientNet) since it takes time to train. Loading the pre trained weight will help get to desired accuracy quicker .

Describe the solution you'd like

An option in the config file that can load the pre trained weight and then resume training from there.

Additional context

No response

@blaz-r
Copy link
Contributor

blaz-r commented Jan 1, 2024

Hello. You can achieve this by adding resume_from_checkpoint somewhere in your config and providing a path to weights that you want to resume from.

This is not that well documented I thing. So I'll note it down as something that should be improved in v1 docs.

@samet-akcay
Copy link
Contributor

Yes, let's keep this issue open as a doc improvement.

@samet-akcay samet-akcay added Documentation Improvements or additions to documentation and removed Task labels Jan 2, 2024
@samet-akcay samet-akcay changed the title [Task]: Add the feature to resume training from a previous training 📘 Add the feature to resume training from a previous training Jan 2, 2024
@samet-akcay samet-akcay added this to the v1.0.0 milestone Jan 2, 2024
@samet-akcay samet-akcay changed the title 📘 Add the feature to resume training from a previous training 📚 v1 - Add the feature to resume training from a previous training Jan 10, 2024
@samet-akcay samet-akcay changed the title 📚 v1 - Add the feature to resume training from a previous training 📚 v1 - Docs Add the feature to resume training from a previous training Feb 29, 2024
@samet-akcay samet-akcay modified the milestones: v1.0.0, v1.1.0 Feb 29, 2024
@Shakib-IO
Copy link
Contributor

Hi @samet-akcay @blaz-r
I want to work on this.

@samet-akcay
Copy link
Contributor

@Shakib-IO, sure go ahead. Thanks for your interest!

@Shakib-IO
Copy link
Contributor

Hi @blaz-r
I'm unsure where I should insert resume_from_checkpoint in the documentation. Any insight you could provide would be greatly appreciated. I found a relevant source here.

Thanks!

@blaz-r
Copy link
Contributor

blaz-r commented Mar 7, 2024

Hi @Shakib-IO resume_from_checkpoint was part of config before the v1. With v1, this is a bit different. You can pass the checkpoint to fit directly:

def fit(
self,
model: AnomalyModule,
train_dataloaders: TRAIN_DATALOADERS | None = None,
val_dataloaders: EVAL_DATALOADERS | None = None,
datamodule: AnomalibDataModule | None = None,
ckpt_path: str | Path | None = None,
) -> None:
"""Fit the model using the trainer.
Args:
model (AnomalyModule): Model to be trained.
train_dataloaders (TRAIN_DATALOADERS | None, optional): Train dataloaders.
Defaults to None.
val_dataloaders (EVAL_DATALOADERS | None, optional): Validation dataloaders.
Defaults to None.
datamodule (AnomalibDataModule | None, optional): Lightning datamodule.
If provided, dataloaders will be instantiated from this.
Defaults to None.
ckpt_path (str | None, optional): Checkpoint path. If provided, the model will be loaded from this path.
Defaults to None.
CLI Usage:
1. you can pick a model, and you can run through the MVTec dataset.
```python
anomalib fit --model anomalib.models.Padim
```
2. Of course, you can override the various values with commands.
```python
anomalib fit --model anomalib.models.Padim --data <CONFIG | CLASS_PATH_OR_NAME> --trainer.max_epochs 3
```
4. If you have a ready configuration file, run it like this.
```python
anomalib fit --config <config_file_path>
```
"""

so passing --ckpt_path CKPT_PATH.
As for setting this via config, I am not sure how this exactly it's handled there.

@ashwinvaidya17
Copy link
Collaborator

@Shakib-IO are you still working on this?

@Shakib-IO
Copy link
Contributor

No. @ashwinvaidya17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants