-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Implement AutoAugment for Detection #6609
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
Open
ain-soph
wants to merge
45
commits into
pytorch:main
Choose a base branch
from
ain-soph:Implement-AutoAugment-for-Detection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 43 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
0bd673b
init commit
ain-soph e29e444
a small update
ain-soph 08f5d12
update
ain-soph 779c1a6
fix type checking issues
ain-soph dcd3f18
Merge branch 'pytorch:main' into Implement-AutoAugment-for-Detection
ain-soph 0e8df49
(In Progress) temp commit
ain-soph 16f6823
finish the majority
ain-soph 75740f2
Merge branch 'Implement-AutoAugment-for-Detection' into main
ain-soph a01572b
Merge pull request #1 from ain-soph/main
ain-soph 0dfc95b
Merge branch 'pytorch:main' into Implement-AutoAugment-for-Detection
ain-soph e712bc5
update
ain-soph 936c704
remove pyd files
ain-soph 20fc9a5
fix type linting errors
ain-soph b7a8adf
add test
ain-soph faa1187
format test file
ain-soph 7daaf98
Merge branch 'pytorch:main' into Implement-AutoAugment-for-Detection
ain-soph 04ebdc7
update codes
ain-soph 115136e
Merge branch 'pytorch:main' into Implement-AutoAugment-for-Detection
ain-soph 1c8f0bc
fix test file
ain-soph d46d4c7
another test fix
ain-soph c813b33
Merge branch 'main' into Implement-AutoAugment-for-Detection
ain-soph df667d5
Merge branch 'main' of github.com:pytorch/vision into Implement-AutoA…
vfdev-5 60d5a9b
Few fixes and improvements
vfdev-5 da70616
Merge branch 'pytorch:main' into Implement-AutoAugment-for-Detection
ain-soph 4e6e8a7
Merge branch
ain-soph 8bbacdb
update
ain-soph 87dd82d
add solarize_add and cutout, add test
ain-soph 48b5539
fix cutout bbox case
ain-soph e38d9ed
fix solarize_add and cutout
ain-soph a38df46
remove 2 useless comments
ain-soph b15cb71
add some comments
ain-soph 73316eb
fix type linting
ain-soph 6020bbc
Merge branch 'pytorch:main' into Implement-AutoAugment-for-Detection
ain-soph 2444128
Merge branch 'main' into Implement-AutoAugment-for-Detection
ain-soph ebc4341
update
ain-soph 338d4ed
remove test policy
ain-soph 8a8a569
Merge branch 'main' into Implement-AutoAugment-for-Detection
ain-soph bb1013a
Merge branch 'main' into Implement-AutoAugment-for-Detection
ain-soph 29c9db5
remove todos
ain-soph 417b744
Merge branch 'Implement-AutoAugment-for-Detection' of https://github.…
ain-soph 4e978b1
Merge branch 'pytorch:main' into Implement-AutoAugment-for-Detection
ain-soph 791d620
update
ain-soph 3afeb30
AutoAugmentDetection -> _AutoAugmentDetection before we validate the …
vfdev-5 89f22ce
Merge branch 'main' into Implement-AutoAugment-for-Detection
ain-soph 5425d95
Merge branch 'main' into Implement-AutoAugment-for-Detection
ain-soph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,28 @@ def auto_augment_adapter(transform, input, device): | |
return adapted_input | ||
|
||
|
||
def auto_augment_detection_adapter(transform, input, device): | ||
adapted_input = {} | ||
image_or_video_found = False | ||
bounding_box_found = False | ||
for key, value in input.items(): | ||
if isinstance(value, datapoints.Mask): | ||
# AA detection transforms don't support masks | ||
continue | ||
elif isinstance(value, datapoints.BoundingBox): | ||
if bounding_box_found: | ||
# AA detection transforms only support a single bounding box tensor | ||
continue | ||
bounding_box_found = True | ||
elif check_type(value, (datapoints.Image, datapoints.Video, is_simple_tensor, PIL.Image.Image)): | ||
if image_or_video_found: | ||
# AA transforms only support a single image or video | ||
continue | ||
image_or_video_found = True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We may want to test different images and videos |
||
adapted_input[key] = value | ||
return adapted_input | ||
|
||
|
||
def linear_transformation_adapter(transform, input, device): | ||
flat_inputs = list(input.values()) | ||
c, h, w = query_chw( | ||
|
@@ -119,6 +141,10 @@ class TestSmoke: | |
(transforms.AutoAugment(), auto_augment_adapter), | ||
(transforms.RandAugment(), auto_augment_adapter), | ||
(transforms.TrivialAugmentWide(), auto_augment_adapter), | ||
(transforms._AutoAugmentDetection("v0"), auto_augment_detection_adapter), | ||
(transforms._AutoAugmentDetection("v1"), auto_augment_detection_adapter), | ||
(transforms._AutoAugmentDetection("v2"), auto_augment_detection_adapter), | ||
(transforms._AutoAugmentDetection("v3"), auto_augment_detection_adapter), | ||
(transforms.ColorJitter(brightness=0.1, contrast=0.2, saturation=0.3, hue=0.15), None), | ||
(transforms.Grayscale(), None), | ||
(transforms.RandomAdjustSharpness(sharpness_factor=0.5, p=1.0), None), | ||
|
@@ -310,6 +336,37 @@ def test_common(self, transform, adapter, container_type, image_or_video, device | |
def test_auto_augment(self, transform, input): | ||
transform(input) | ||
|
||
@pytest.mark.parametrize( | ||
"transform", | ||
[ | ||
transforms._AutoAugmentDetection("v0"), | ||
transforms._AutoAugmentDetection("v1"), | ||
transforms._AutoAugmentDetection("v2"), | ||
transforms._AutoAugmentDetection("v3"), | ||
], | ||
) | ||
@pytest.mark.parametrize("seed", range(10)) | ||
def test_auto_augment_detection(self, transform, seed): | ||
torch.manual_seed(seed) | ||
image = datapoints.Image(torch.randint(0, 256, size=(3, 480, 640), dtype=torch.uint8)) | ||
boxes = torch.tensor( | ||
[ | ||
[388.3100, 38.8300, 638.5600, 480.0000], | ||
[82.6800, 314.7300, 195.4400, 445.7400], | ||
[199.1000, 214.1700, 316.4100, 399.2800], | ||
[159.8400, 183.6800, 216.8700, 273.1200], | ||
[15.8000, 265.4600, 93.2900, 395.1800], | ||
[88.2300, 266.0800, 222.9800, 371.2500], | ||
[176.9000, 283.8600, 208.4300, 292.3000], | ||
[537.6300, 230.8300, 580.7100, 291.3300], | ||
[421.1200, 230.4700, 580.6700, 350.9500], | ||
[427.4200, 185.4300, 494.0200, 266.3500], | ||
] | ||
) | ||
bboxes = datapoints.BoundingBox(boxes, format="XYXY", spatial_size=image.shape[-2:]) | ||
input = (image, bboxes) | ||
transform(input) | ||
|
||
@parametrize( | ||
[ | ||
( | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.