You want to create a custom function for the get_items
parameter if your goal is pre-filtering the files to only bring in numbers where the file name %3 == 0. You can see an example of a custom get_items
function here: Read data from different directories - #4 by matdmiller . If all you are doing is loading images, you probably do not need to write a custom function for (or even define) the get_x
parameter. The get_y
parameter is the function for loading in the labels. It looks like you are trying to filter your files by defining a custom function for get_y
which is not correct. It’s hard to know what get_y
should be without knowing what you’re trying to train the model to do. Here is another example of some custom datablock implementations which may help lead you in the right direction: Multi-GPU w/ PyTorch? - #5 by matdmiller . In this second example I am doing semantic segmentation and loading a mask for the y
variable.
A function something like this may be what you’re after…
def my_get_items_function(x):
img_files = get_image_files('./my/image/file/path')
filtered_img_files = []
for img_fname in img_files:
if int(str(img_fname.name)[4:8])%3 == 0:
filtered_img_files.append(img_fname)
return filtered_img_files
...
get_items=my_get_items_function
...