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

Set transformations from the config file #990

Merged

Conversation

alexriedel1
Copy link
Contributor

This PR allows to define image augmentations and transforms that are part of the albumentations module to be defined in the model config file.

This becomes possible now:

dataset:
  name: mvtec
  format: mvtec
  path: ./datasets/MVTec
  task: segmentation
  category: bottle
  train_batch_size: 32
  test_batch_size: 32
  num_workers: 8
  image_size: 256 # dimensions to which images are resized (mandatory)
  center_crop: 224 # dimensions to which images are center-cropped after resizing (optional)
  normalization: imagenet # data distribution to which the images will be normalized: [none, imagenet]
  transform_config:
    train:
      Resize:
        height: 256
        width: 256
        always_apply: true
      Normalize:
        mean: [0.485, 0.456, 0.406]
        std: [0.229, 0.224, 0.225]
    eval:
      Resize:
        height: 256
        width: 256
        always_apply: true
      Normalize:
        mean: [0.485, 0.456, 0.406]
        std: [0.229, 0.224, 0.225]

It not only helps readability but also allows for image augmentations to be used in HPO sweeps

@ashwinvaidya17 ashwinvaidya17 requested a review from djdameln March 31, 2023 07:41
Copy link
Collaborator

@ashwinvaidya17 ashwinvaidya17 left a comment

Choose a reason for hiding this comment

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

Thanks! This is very useful

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain the changes to this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you perform HPO sweeps on colab, the GPU memory isn't freed after each run and accumulates over time. To solve this, the model needs to be deleted and torch cache has to be cleared:
https://stackoverflow.com/a/57569472/11951277

@samet-akcay
Copy link
Contributor

@alexriedel1, not sure you noticed, but pre-commit checks failed due to the following error

src/anomalib/utils/hpo/runners.py:6:1: I001 [*] Import block is un-sorted or un-formatted
Found 1 error.

@alexriedel1
Copy link
Contributor Author

@alexriedel1, not sure you noticed, but pre-commit checks failed due to the following error

src/anomalib/utils/hpo/runners.py:6:1: I001 [*] Import block is un-sorted or un-formatted
Found 1 error.

yess, working on it :)

@github-actions github-actions bot added the Setup label Apr 4, 2023
@github-actions github-actions bot removed the Setup label Apr 4, 2023
@alexriedel1
Copy link
Contributor Author

alexriedel1 commented Apr 4, 2023

from the failing pre-commit checks:

[2023-04-04T09:58:21.403Z] ['error'] There was an error running the uploader: 
Unable to detect SHA and slug, please specify them manually.

Thats not on my side right?

@samet-akcay
Copy link
Contributor

from the failing pre-commit checks:

[2023-04-04T09:58:21.403Z] ['error'] There was an error running the uploader: 
Unable to detect SHA and slug, please specify them manually.

Thats not on my side right?

No, it sometimes happens when the coverage is uploaded to codecov. The tests pass. We could merge this.

Thanks again! :)

@samet-akcay samet-akcay merged commit 27adbae into openvinotoolkit:main Apr 4, 2023
@sudhanv09
Copy link

sudhanv09 commented Apr 12, 2023

Hi can you give some more examples of how to do this. I have been searching for transform config but to no avail. I found your method but the yaml parser always fails to parse. Thanks

@alexriedel1
Copy link
Contributor Author

Hi can you give some more examples of how to do this. I have been searching for transform config but to no avail. I found your method but the yaml parser always fails to parse. Thanks

Do you have installed the latest version? What exact errors are you getting?

@sudhanv09
Copy link

Ah my bad i was on the release version, now I have installed this dev version, it works. Thanks

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.

5 participants