Decouple feature extractor from models and wrap the dataset instead #694
Replies: 2 comments 5 replies
-
I like this idea. We won't have to pass the image through the feature extractor each time the same image is passed to the model during training. I am concerned about the memory usage but we can think of some design that mitigates that. |
Beta Was this translation helpful? Give feedback.
-
I guess this could be taken into account when working on the new tiling design |
Beta Was this translation helpful? Give feedback.
-
Context
Several methods have the feature extraction as the first step of the pipeline, and (unless your dataset uses data augmentation) a feature vector will always be the same given an image and a pre-trained model.
Idea
I propose to make a wrapper for (not sure which or all) DataLoader/DataSet/DataModule (DL/DS/DM), most likely, with a decorator
that carries a (frozen? for the sake of reproducibility and simplicity) feature extractor network inside.
Its role is to extract the feature and pass it along so the models don't have to implement this.
Downstream features
With such mechanism, both features below would be possible/available to any model.
1) cache the feature vectors [by image idx] to speed up training
A simple cache mechanism like
functools.cache
would make the feature extraction faster during trainings that iterate over the dataset multiple times.2) Augmentations in the feature space
One can play both with augmentations in the image space (as it's done with the
transform_config
now) and then on the feature space as well. And this could also be eventually cached.Beta Was this translation helpful? Give feedback.
All reactions