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

How to test the trained model of .ckpt format #13

Open
yihp opened this issue Aug 22, 2024 · 11 comments
Open

How to test the trained model of .ckpt format #13

yihp opened this issue Aug 22, 2024 · 11 comments

Comments

@yihp
Copy link

yihp commented Aug 22, 2024

Hi! Thanks for your contribution. It is an excellent piece of work!

The trained model is saved in last.ckpt format, but it cannot be directly tested using the test command in the repository.

dlhpcstarter -t cxrmate_hf -c config/test_huggingface/longitudinal_gen_prompt_cxr-bert.yaml --stages_module tools.stages --test

What adjustments should I make?

Thank you very much for your time and consideration. I eagerly look forward to your response.

@anicolson
Copy link
Member

You should be able to use this in either your config or as a command line argument: https://github.com/csiro-mlai/dl_hpc_starter_pack/blob/352bf81e8d9aefcb31cfef2a9c4ce77504a394bc/src/dlhpcstarter/command_line_arguments.py#L79

--test-ckpt-path /path/to/last.ckpt

@anicolson
Copy link
Member

It will get passed to:

args.exp_dir_trial, args.monitor, args.monitor_mode, args.test_epoch, args.test_ckpt_path,

And then...: https://github.com/csiro-mlai/dl_hpc_starter_pack/blob/352bf81e8d9aefcb31cfef2a9c4ce77504a394bc/src/dlhpcstarter/utils.py#L291

And it will eventually just be given as the ckpt path to...:

model = TaskModel.load_from_checkpoint(checkpoint_path=ckpt_path, **vars(args))

@yihp
Copy link
Author

yihp commented Aug 22, 2024

thanks very much for the detailed process, I will try it

@yihp
Copy link
Author

yihp commented Aug 22, 2024

hi @anicolson ,

I found that I had to delete the parameters --test-ckpt-name and --other-exp-dir in command_line_arguments.py and then pass in the parameters --test-ckpt-path to load the trained model last.ckpt for testing.
I think it is because of hasattr(args, 'test_ckpt_name') and hasattr(args, 'other_exp_dir'). As long as the parameter test_ckpt_name and other_exp_dir is included in command_line_arguments.py, Then the corresponding code logic will be executed without loading the trained model last.ckpt.
In addition, my dlhpcstarter is installed in \usr\local\lib\python3.8\site-packages\dlhpcstarter, which is not very convenient to modify. I am currently using the soft link method. Do you have a better way?

@anicolson
Copy link
Member

What version of dlhpcstarter are you using? Can you try with 0.1.7?

@anicolson
Copy link
Member

If it doesn't work, i'll have a look soon

@yihp
Copy link
Author

yihp commented Aug 22, 2024

The dlhpcstarter version I used was 0.1.7, but I delete the parameters --test-ckpt-name and --other-exp-dir in \usr\local\lib\python3.8\site-packages\command_line_arguments.py and it worked.

@anicolson
Copy link
Member

Okay. I'll update the dlhpcstarter pack to fix that problem. Will let you know when its fixed.

@yihp
Copy link
Author

yihp commented Aug 22, 2024

That's great, thank u very much

@anicolson
Copy link
Member

@yihp
Copy link
Author

yihp commented Aug 27, 2024

thanks very much for the detailed process, I will try 0.1.8

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

No branches or pull requests

2 participants