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

Example code #1

Open
no-clue-what-to-do opened this issue May 10, 2022 · 4 comments
Open

Example code #1

no-clue-what-to-do opened this issue May 10, 2022 · 4 comments

Comments

@no-clue-what-to-do
Copy link

Could you post an example of using the spectral denoising model with python? I'm very interested in trying out your methods on my own data, but I'm confused about how to interface my data and how to use your scripts. Is it possible to write a standalone script to train a model with the architecture you use, or do I have to edit the train.py file?

Thanks!

@conor-horgan
Copy link
Owner

Hi,

If you would like to train a denoising model using an architecture already implemented in spectrai, the only thing you would need to create/modify is a .yaml config file that defines your setup. An example config file for denoising can be found here. You can edit the various different settings and parameters to suit your case. In particular, you will have to edit the paths for input and target data under DataManger_Options. Note that this assumes that your spectral data is stored as an array of size (n x L) where n is the number of spectra in your dataset and L is the spectral length (either as a .mat or a .npy file).

Then, to train you can type (once you have installed spectrai):

>> spectrai_train --config custom_config.yml --verbose

Where custom_config.yml is the custom config file you have created and saved in the spectrai configs directory.

If you are interested in a standalone spectral denoising model in Python (without some of the overheads of using spectrai) you can also check out DeepeR

@no-clue-what-to-do
Copy link
Author

Where does the model get saved when you do this procedure? I see that a I have new tensorboard data, but I don't see where a model was saved

@conor-horgan
Copy link
Owner

The save_output function defines where models are saved. This will create a new folder called 'saved_models' in the spectrai directory. This function is called in the train_epoch function here.

@no-clue-what-to-do
Copy link
Author

Hey,

So I actually used the train_epoch function on its own and didn't get a saved model for some reason. I got it to work by changing the save_frequency to 1 instead of zero. No clue why this would do the trick, because the logic on line 130 of trainer.py seems to work properly when save frequency is set to zero.

I didn't use the spectra_train command because my system isn't recognizing (even though I have spectrai installed with pip). Not sure why this isn't working either.

Sorry for the kind of basic questions. I'm jsut trying to compare multiple methods of spectral denoising for Raman spectra and I'm reading a lot of new code that I'm not used to! Thanks so much for making this public, really appreciate it

Kevin

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