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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: RandomJPEG bug with different devices #2883

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ditwoo
Copy link

@ditwoo ditwoo commented Apr 13, 2024

Changes

Fixes #2867

Type of change

  • 馃摎 Documentation Update
  • 馃И Tests Cases
  • [+] 馃悶 Bug fix (non-breaking change which fixes an issue)
  • 馃敩 New feature (non-breaking change which adds functionality)
  • 馃毃 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 馃摑 This change requires a documentation update

Checklist

  • [+] My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Did you update CHANGELOG in case of a major change?

@johnnv1 johnnv1 added bug 馃悰 Something isn't working module: augmentations labels Apr 14, 2024
Copy link
Member

@johnnv1 johnnv1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even though it fixes your issue, this shouldn't be necessary...

The real issue is in the random generator

return {"jpeg_quality": jpeg_quality_value.to(device=_device, dtype=_dtype)}
which is allocating and then casting it to the wrong device

Can you test if in this case, where you want to use the nontensor as the bounds inputs, if you use the

import torch
from kornia.augmentation import RandomJPEG

device = "cuda"
jpegq = (1.0, 50.0)
aug = RandomJPEG(jpeg_quality=jpegq, p=1.0)
aug.set_rng_device_and_dtype(device=torch.device(device), dtype=torch.float32)
example_input = torch.randn((3, 224, 224)).to(device)
res = aug(example_input)

btw, should this really be necessary? cc @shijianjian @edgarriba

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

Successfully merging this pull request may close these issues.

RandomJPEG can't handle input on different from CPU device.
2 participants