royerlab / aydin

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

Not finding model zipped folder #74

Closed juliomateoslangerak closed 2 years ago

juliomateoslangerak commented 2 years ago

Hi, It seems that, for some reason I cannot figure out, Aydin cannot find the zipped model file. It does not happen every time, so I do not think it is an installation issue. I would say it is rather a problem with zipping the folder, as the folder is in place and with a bunch of files inside:

/home/julio/temp/Aydin_tests/20211103_Aux-async_1225_p008_training.ome_options3.json
/home/julio/temp/Aydin_tests/20211103_Aux-async_1225_p008_training.ome_denoised3.tif
/home/julio/temp/Aydin_tests/20211103_Aux-async_1225_p008_training.ome_model3
  /home/julio/temp/Aydin_tests/20211103_Aux-async_1225_p008_training.ome_model3/channel0
    /home/julio/temp/Aydin_tests/20211103_Aux-async_1225_p008_training.ome_model3/channel0/lgbm_model.txt
    /home/julio/temp/Aydin_tests/20211103_Aux-async_1225_p008_training.ome_model3/channel0/regressor_model.json
  /home/julio/temp/Aydin_tests/20211103_Aux-async_1225_p008_training.ome_model3/channel1
    /home/julio/temp/Aydin_tests/20211103_Aux-async_1225_p008_training.ome_model3/channel1/lgbm_model.txt
    /home/julio/temp/Aydin_tests/20211103_Aux-async_1225_p008_training.ome_model3/channel1/regressor_model.json
  /home/julio/temp/Aydin_tests/20211103_Aux-async_1225_p008_training.ome_model3/feature_generation.json
  /home/julio/temp/Aydin_tests/20211103_Aux-async_1225_p008_training.ome_model3/image_translation.json
  /home/julio/temp/Aydin_tests/20211103_Aux-async_1225_p008_training.ome_model3/regressor.json
DONE, options json written in /home/julio/temp/Aydin_tests/20211103_Aux-async_1225_p008_training.ome_options3.json 
├╗ Saving 'fgr' image translator to /home/julio/temp/Aydin_tests/20211103_Aux-async_1225_p008_training.ome_model3 
│├  Saving image translator to: /home/julio/temp/Aydin_tests/20211103_Aux-async_1225_p008_training.ome_model3 
│├  Saving feature generator to: /home/julio/temp/Aydin_tests/20211103_Aux-async_1225_p008_training.ome_model3 
│├  Saving regressor to: /home/julio/temp/Aydin_tests/20211103_Aux-async_1225_p008_training.ome_model3 
│┴« 6.02 seconds 
│ 
├  Previously existing model will be deleted before saving the new model 
Traceback (most recent call last):
  File "/home/julio/.conda/envs/aydin_env/lib/python3.9/shutil.py", line 815, in move
    os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: '20211103_Aux-async_1225_p008_training.ome_model3.zip' -> '/home/julio/temp/Aydin_tests/20211103_Aux-async_1225_p008_training.ome_model3.zip'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/julio/.conda/envs/aydin_env/lib/python3.9/site-packages/aydin/gui/_qt/job_runners/worker.py", line 67, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/julio/.conda/envs/aydin_env/lib/python3.9/site-packages/aydin/gui/_qt/job_runners/denoise_job_runner.py", line 81, in start_func
    self.denoiser.save_model(model_path)
  File "/home/julio/.conda/envs/aydin_env/lib/python3.9/site-packages/aydin/restoration/denoise/base.py", line 167, in save_model
    self.archive_model(model_path, os.path.dirname(model_path))
  File "/home/julio/.conda/envs/aydin_env/lib/python3.9/site-packages/aydin/restoration/denoise/base.py", line 153, in archive_model
    shutil.move(f"{name}.{format}", destination)
  File "/home/julio/.conda/envs/aydin_env/lib/python3.9/shutil.py", line 835, in move
    copy_function(src, real_dst)
  File "/home/julio/.conda/envs/aydin_env/lib/python3.9/shutil.py", line 444, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/home/julio/.conda/envs/aydin_env/lib/python3.9/shutil.py", line 264, in copyfile
    with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: '20211103_Aux-async_1225_p008_training.ome_model3.zip

OS is Fedora34 installation through conda

Do you have an idea of something I could try?

AhmetCanSolak commented 2 years ago

hello @juliomateoslangerak ! Thank you for the issue.

At first glance it seems like a problem with zipping. I need to know a little more to understand when this problem occurs exactly. It seems like you are using Noise2SelfFGR-lgbm. Are you getting this error only with lgbm or with other FGR variants too? and I am curious if you are getting this error with particular images only?

If you have a piece of data and your set of options that you can share to reproduce this error, I highly appreciate that.

AhmetCanSolak commented 2 years ago

Hi @juliomateoslangerak again, I realized a little issue that sometimes causing trouble while zipping the model and fixed in #81 . You can install Aydin from latest master to get the fix and give it a try for now or later this month I will be releasing a new version of Aydin which will include this fix.

juliomateoslangerak commented 2 years ago

Sorry for ont following on this. Busy days lately. So it is difficult to find a reproducible pattern. If I reboot the PC everything works fine again for a few times and, at some point it doesn’t. Restarting Aydin does not solve the issue. Still want to check if reactivating the conda environment is helping. The dataset is a 2 channel 3D stack in ome-tif format. Recognition of dimensions is fine.

I will give it a shot when you release if I cannot find a gap in between.

AhmetCanSolak commented 2 years ago

out of curiosity pinging, have you tried with the latest version @juliomateoslangerak ?

AhmetCanSolak commented 2 years ago

I will be closing this issue @juliomateoslangerak , please feel free to re-open it if the problem occurs again.

juliomateoslangerak commented 2 years ago

Sorry for my delayed answer. I didn't have time to try out this before. Just for the record, I have tried with the current version and the problem does not reproduce.