Is there a way to apply transformations to only selected images?
To be more precise, I’d like in sequence of code below:
data = src.transform(tfms)
to apply the transformations only to images having names with specific patterns. Another application would be to make data augmentation only for some part of the
Of course a workaround would be to create additional images upfront of the process.
+1. I have the same need. I want to apply certain types of transforms to images based on their file name. That would be a welcome addition to the options of the
Use “filters” on src:
Note: it changes your “src” so save/duplicate it first.
filter_by_func and co filter data that are read into the input list? What we want to do is apply transforms selectively on all input images, not filter when reading in the data.
I’d recommend looking at the
__get_item__ method in the LabelList class. You could write a custom LabelList which overloads
__get_item__ and only applies transforms if the input passes some filter. Then, you can monkey patch that custom class into the usual data block flow like this:
src = (ImageList.from_folder(path)
src.train._label_list = CustomLabelListClass
data = (src.label_from_folder()
It’s not elegant, but I’ve been using this technique to alter how augmentation is applied.