royerlab / aydin

Aydin — User-friendly, Fast, Self-Supervised Image Denoising for All.
https://royerlab.github.io/aydin/
BSD 3-Clause "New" or "Revised" License
151 stars 14 forks source link

Unable to load pre-trained model using the api #300

Closed zacswider closed 1 year ago

zacswider commented 1 year ago

Hello, I am trying to denoise a batch of images with a pre-trained FGR (CatBoost) model.

To Reproduce

from aydin.restoration.denoise.noise2selffgr import Noise2SelfFGR
from tifffile import imread

noisy_image_path = 'path/to/noisy_im.tif'
noisy_image = imread(noisy_image_path)
n2s = Noise2SelfFGR(variant = 'cb', use_model = True, input_model_path = "path/to/pretrained_model.zip")
denoised = n2s.denoise(noisy_image)

Expected behavior I can run the equivalent command through the command line:

aydin denoise *.tif --model-path=path/to/pretrained_model.zip --model-model

and see that aydin quickly generates denoised images with the pretrained model.

Screenshots image

Desktop (please complete the following information):

Additional context I tried installing the main github branch in a separate environment and the error persisted.

This is amazing software, thank you to all the developers!

AhmetCanSolak commented 1 year ago

Hello @zacswider , thank you for the issue.

Unfortunately, some legacy parameters caused a confusion here. You will need to use the load method given here : https://royerlab.github.io/aydin//v0.1.15/api/restorations/denoise_restoration.html#aydin.restoration.denoise.noise2selffgr.Noise2SelfFGR.load You will not need to pass any parameters while constructing Noise2SelfFGR

You can find code example for it here: https://github.com/royerlab/aydin/blob/9312f227605be26fce960373c1f29a71323da914/aydin/restoration/denoise/test/test_saveload.py#L58

Please let me know if this helps, I will be making a PR to clarify Noise2SelfFGR parameters. Also, let me know if there is anything else I can help with. Thank you for using Aydin.

zacswider commented 1 year ago

Thanks for clarifying Ahmet! Everything is running smoothly now :)