Skip to content

ignore one class subfolder while using image_dataset_from_directory() function #1386

@maitra

Description

@maitra

I am looking into the R package keras and the function image_dataset_from_directory()

According to the help page,

 If your directory structure is:

 main_directory/
 ...class_a/
 ......a_image_1.jpg
 ......a_image_2.jpg
 ...class_b/
 ......b_image_1.jpg
 ......b_image_2.jpg

Then calling ‘image_dataset_from_directory(main_directory, labels='inferred')’ will return a ‘tf.data.Dataset’ that yields batches of images from the subdirectories class_a and class_b, together with labels 0 and 1 (0 corresponding to class_a and 1 corresponding to class_b).

However, I have three folders:

   main_directory/
 ...class_a/
 ......a_image_1.jpg
 ......a_image_2.jpg
 ...
 ...class_b/
 ......b_image_1.jpg
 ......b_image_2.jpg
 ...
...class_c/
 ......c_image_1.jpg  
 ......c_image_1.jpg
 ...

I want to read only two of these classes (and ignore the third). Is there a way to do this using the image_dataset_from_directory() or some other function?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions