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

How to take some sub-directories from a main directory tf.keras.utils.image_dataset_from_directory #187

Closed
ARPIT2128 opened this issue May 28, 2023 · 2 comments · Fixed by keras-team/keras#18177
Assignees

Comments

@ARPIT2128
Copy link

How to take some sub-directories from a main directory

  • Hello I'm new to this issue stuff 😃
  • Basically I was unable to find a fix for the issue on Stackoverflow so I'm here to ask the experts. 💜
  • Hope I'm not creating a problem for you all will make it short and simple. 😥
def image_dataset_from_directory(
    directory,
    labels="inferred",
    label_mode="int",
    class_names=None,
    color_mode="rgb",
    batch_size=32,
    image_size=(256, 256),
    shuffle=True,
    seed=None,
    validation_split=None,
    subset=None,
    interpolation="bilinear",
    follow_links=False,
    crop_to_aspect_ratio=False,
    **kwargs,
):
  • HERE IF I ONLY WANT class_a THEN WHAT TO DO
    main_directory/
    ...class_a/
    ......a_image_1.jpg
    ......a_image_2.jpg
    ...class_b/
    ......b_image_1.jpg
    ......b_image_2.jpg

image

  • As shown in above figure I'm trying to use the tf.keras.utils.image_dataset_from_directory
  • But here I want to take some sub directories only and not all like .git files from the main directory
  • Previously it was in from tensorflow.keras.preprocessing.image import image_dataset_from_directory
  • with parameter ignore
  • is there a easy fix for this using this directory or any relevant.
    THANKS IN ADVANCE 😉
@sachinprasadhs
Copy link
Collaborator

Hi,

Thanks for reporting the issue.
I was able to verify the issue in colab.

image

I have created a PR to handle the hidden folders like .git , .ipynb etc.

Coming to your question about ignoring directory with directory name as input is not possible in the current implementation as per my understanding.

copybara-service bot referenced this issue in keras-team/keras Jun 30, 2023
Imported from GitHub PR #18177

Ignore hidden folders for image_dataset_from_directory like .git .ipynb etc.
Fixes: https://github.com/keras-team/keras/issues/18170
Copybara import of the project:

--
489e279 by Sachin Prasad <[email protected]>:

Ignore hidden folders for image_dataset_from_directory

Ignore hidden folders for image_dataset_from_directory like .git .ipynb etc.
--
ed62b30 by Sachin Prasad <[email protected]>:

Ignore hidden folders for image_dataset_from_directory
--
3f86351 by Sachin Prasad <[email protected]>:

Ignore hidden folders for image_dataset_from_directory
--
64d91d4 by Sachin Prasad <[email protected]>:

Ignore hidden folders for image_dataset_from_directory
--
9870b10 by Sachin Prasad <[email protected]>:

Ignore hidden folders for image_dataset_from_directory
--
31af45e by Sachin Prasad <[email protected]>:

Ignore hidden folders for image_dataset_from_directory
--
9bc903b by Sachin Prasad <[email protected]>:

Ignore hidden folders for image_dataset_from_directory
--
e337f3a by Sachin Prasad <[email protected]>:

Ignore hidden folders for image_dataset_from_directory

Merging this change closes #18177

FUTURE_COPYBARA_INTEGRATE_REVIEW=#18177 from keras-team:sachinprasadhs-patch-5 e337f3a
PiperOrigin-RevId: 544701876
@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@fchollet fchollet transferred this issue from keras-team/keras Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants