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

[AI-1287] fixed the siutation when a user pass only a image #696

Conversation

ChristofferEdlund
Copy link
Contributor

Problem

One should be able to user the albumentations transform in this way:


transform = AlbumentationsTransform(transform_compse())
img_tensor = transform(img)

Right now the transform output's a (img, target) tuple even when only an image is passed.

Solution

Add a check if there is only an image as input, and return only image if that is the case.

Changelog

  • albumentation transform now returns only img and not (img, target) when only an image is present as input

@linear
Copy link

linear bot commented Oct 23, 2023

@ChristofferEdlund ChristofferEdlund changed the title fixed the siutation when a user pass only a image [AI-1287] fixed the siutation when a user pass only a image Oct 23, 2023
@dorfmanrobert dorfmanrobert self-requested a review October 23, 2023 14:45
… is to throw an error and not let the user include images without annotations
@dorfmanrobert dorfmanrobert self-requested a review October 23, 2023 15:31
darwin/torch/transforms.py Outdated Show resolved Hide resolved
darwin/torch/transforms.py Outdated Show resolved Hide resolved
darwin/torch/transforms.py Show resolved Hide resolved
darwin/torch/transforms.py Outdated Show resolved Hide resolved
output_annotation["masks"] = torch.tensor([])

if "area" in annotation:
if "masks" in output_annotation and output_annotation["masks"].numel() > 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

stylistic choice: could use masks and bboxes variables since have them but up to you

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we keep at as it is, masks and bboxes are not the same since we do some conversion. masks for example is a list, and does not have .numel

@dorfmanrobert
Copy link
Contributor

left one stylistic comment abt using existing variables or not that I leave up to you, otherwise all good!

@ChristofferEdlund ChristofferEdlund merged commit 6de0be9 into master Oct 23, 2023
13 checks passed
@ChristofferEdlund ChristofferEdlund deleted the ai-1287-fixed-darwin-albumentation-transform-format-when-only branch October 23, 2023 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants