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

rep_crop ZeroDivisionError #207

Open AhmetCanSolak opened 2 years ago

AhmetCanSolak commented 2 years ago

Describe the bug We get a ZeroDivisionError with an image shape of (2, 84, 580, 576). This issue is a reminder to our future selves.

To Reproduce Steps to reproduce the behavior:

  1. Get two 3D timepoints
  2. Make hyperstack with t=2
  3. Run denoising
  4. See error

Expected behavior No error, smooth run.

Screenshots

Traceback (most recent call last):
  File "/Users/ahmetcan.solak/Dev/AhmetCanSolak/aydin/aydin/gui/_qt/job_runners/worker.py", line 60, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/ahmetcan.solak/Dev/AhmetCanSolak/aydin/aydin/gui/_qt/job_runners/denoise_job_runner.py", line 60, in start_func
    self.denoiser.train(
  File "/Users/ahmetcan.solak/Dev/AhmetCanSolak/aydin/aydin/restoration/denoise/noise2selffgr.py", line 279, in train
    self.it.train(
  File "/Users/ahmetcan.solak/Dev/AhmetCanSolak/aydin/aydin/it/base.py", line 280, in train
    self.blind_spots, autocorrelogram = auto_detect_blindspots(
  File "/Users/ahmetcan.solak/Dev/AhmetCanSolak/aydin/aydin/analysis/blind_spot_analysis.py", line 105, in auto_detect_blindspots
    image = representative_crop(image, crop_size=int(1e6), favour_odd_lengths=True)
  File "/Users/ahmetcan.solak/Dev/AhmetCanSolak/aydin/aydin/util/crop/rep_crop.py", line 235, in representative_crop
    translation = tuple(
  File "/Users/ahmetcan.solak/Dev/AhmetCanSolak/aydin/aydin/util/crop/rep_crop.py", line 236, in <genexpr>
    (randrange(0, max(1, (s - cs) // g)) * g if cs != s else 0)
ZeroDivisionError: integer division or modulo by zero

Additional context Add any other context about the problem here.