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

'RandomResizedCrop' raises exception #279

Closed
SerezD opened this issue Jan 19, 2023 · 2 comments
Closed

'RandomResizedCrop' raises exception #279

SerezD opened this issue Jan 19, 2023 · 2 comments

Comments

@SerezD
Copy link

SerezD commented Jan 19, 2023

I would like to train on Imagenet dataset, and I have set up two different pipelines for train/test:

img_train_pipeline = [CenterCropRGBImageDecoder(output_size=(self.image_size, self.image_size), ratio=1.),
                      RandomResizedCrop(scale=(0.8, 1.), ratio=(0.9, 1.1), size=self.image_size),
                      RandomHorizontalFlip(),
                      ToTensor(),
                      ToTorchImage(),
                      Convert(torch.float16),
                      Normalize(IMAGENET_MEAN, IMAGENET_STD)
                      ]

img_test_pipeline = [CenterCropRGBImageDecoder(output_size=(self.image_size, self.image_size), ratio=1.),
                     ToTensor(), 
                     ToTorchImage(),
                     Convert(torch.float16),
                     Normalize(IMAGENET_MEAN, IMAGENET_STD),
                     ]

The test pipeline works fine, but the train pipeline raises an error. In particular:

Traceback (most recent call last):
  File "/home/dserez/anaconda3/envs/ffcv/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/home/dserez/anaconda3/envs/ffcv/lib/python3.10/site-packages/ffcv/loader/epoch_iterator.py", line 79, in run
    result = self.run_pipeline(b_ix, ixes, slot, events[slot])
  File "/home/dserez/anaconda3/envs/ffcv/lib/python3.10/site-packages/ffcv/loader/epoch_iterator.py", line 133, in run_pipeline
    result = code(*args)
  File "/home/dserez/anaconda3/envs/ffcv/lib/python3.10/site-packages/numba/core/dispatcher.py", line 468, in _compile_for_args
    error_rewrite(e, 'typing')
  File "/home/dserez/anaconda3/envs/ffcv/lib/python3.10/site-packages/numba/core/dispatcher.py", line 409, in error_rewrite
    raise e.with_traceback(None)
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Failed in nopython mode pipeline (step: nopython frontend)
No implementation of function Function(<ufunc 'log'>) found for signature:
 
 >>> log(reflected list(float64)<iv=None>)
 
There are 2 candidate implementations:
  - Of which 2 did not match due to:
  Overload in function 'Numpy_rules_ufunc.generic': File: numba/core/typing/npydecl.py: Line 98.
    With argument(s): '(reflected list(float64)<iv=None>)':
   Rejected as the implementation raised a specific error:
     TypingError: can't resolve ufunc log for types [reflected list(float64)<iv=None>]
  raised from /home/dserez/anaconda3/envs/ffcv/lib/python3.10/site-packages/numba/core/typing/npydecl.py:107
During: resolving callee type: Function(<ufunc 'log'>)
During: typing of call at /home/dserez/anaconda3/envs/ffcv/lib/python3.10/site-packages/ffcv/transforms/utils/fast_crop.py (19)
File "../../../../../anaconda3/envs/ffcv/lib/python3.10/site-packages/ffcv/transforms/utils/fast_crop.py", line 19:
def get_random_crop(height, width, scale, ratio):
    <source elided>
    area = height * width
    log_ratio = np.log(ratio)
    ^
During: resolving callee type: type(CPUDispatcher(<function RandomResizedCrop.generate_code.<locals>.random_resized_crop at 0x7f7d53ce9750>))
During: typing of call at  (2)
During: resolving callee type: type(CPUDispatcher(<function RandomResizedCrop.generate_code.<locals>.random_resized_crop at 0x7f7d53ce9750>))
During: typing of call at  (2)
File "/home/dserez/.../src", line 2:
<source missing, REPL/exec in use?>
Exception in thread Thread-8:
Traceback (most recent call last):
  File "/home/dserez/anaconda3/envs/ffcv/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/home/dserez/anaconda3/envs/ffcv/lib/python3.10/site-packages/ffcv/loader/epoch_iterator.py", line 79, in run
    result = self.run_pipeline(b_ix, ixes, slot, events[slot])
  File "/home/dserez/anaconda3/envs/ffcv/lib/python3.10/site-packages/ffcv/loader/epoch_iterator.py", line 133, in run_pipeline
    result = code(*args)
  File "/home/dserez/anaconda3/envs/ffcv/lib/python3.10/site-packages/numba/core/dispatcher.py", line 468, in _compile_for_args
    error_rewrite(e, 'typing')
  File "/home/dserez/anaconda3/envs/ffcv/lib/python3.10/site-packages/numba/core/dispatcher.py", line 409, in error_rewrite
    raise e.with_traceback(None)
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Failed in nopython mode pipeline (step: nopython frontend)
No implementation of function Function(<ufunc 'log'>) found for signature:
 
 >>> log(reflected list(float64)<iv=None>)
 
There are 2 candidate implementations:
  - Of which 2 did not match due to:
  Overload in function 'Numpy_rules_ufunc.generic': File: numba/core/typing/npydecl.py: Line 98.
    With argument(s): '(reflected list(float64)<iv=None>)':
   Rejected as the implementation raised a specific error:
     TypingError: can't resolve ufunc log for types [reflected list(float64)<iv=None>]
  raised from /home/dserez/anaconda3/envs/ffcv/lib/python3.10/site-packages/numba/core/typing/npydecl.py:107
During: resolving callee type: Function(<ufunc 'log'>)
During: typing of call at /home/dserez/anaconda3/envs/ffcv/lib/python3.10/site-packages/ffcv/transforms/utils/fast_crop.py (19)
File "../../../../../anaconda3/envs/ffcv/lib/python3.10/site-packages/ffcv/transforms/utils/fast_crop.py", line 19:
def get_random_crop(height, width, scale, ratio):
    <source elided>
    area = height * width
    log_ratio = np.log(ratio)
    ^
During: resolving callee type: type(CPUDispatcher(<function RandomResizedCrop.generate_code.<locals>.random_resized_crop at 0x7fc05cea12d0>))
During: typing of call at  (2)
During: resolving callee type: type(CPUDispatcher(<function RandomResizedCrop.generate_code.<locals>.random_resized_crop at 0x7fc05cea12d0>))
During: typing of call at  (2)
File "/home/dserez/.../src", line 2:
<source missing, REPL/exec in use?>
@andrewilyas
Copy link
Contributor

I recently merged in a fix to RandomResizedCrop (#288) so this should be fixed in v1.0 coming out this week!

@andrewilyas
Copy link
Contributor

This should now be fixed and uploaded on PyPI!

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

No branches or pull requests

2 participants