tensorflow / tensorflow/datasets

How to convert my tf.data.dataset into image and label arrays

Open
#2,499 7 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help
Dominant language
Python
Stars
4.6k
Forks
1.6k
Avg merge
3h 54m
Merged PRs (30d)
1

Description

I created a tf.data.dataset using the instructions on the keras.io documentation site.

dataset = tf.keras.preprocessing.image_dataset_from_directory( directory, labels="inferred", label_mode="int", class_names=None, color_mode="rgb", batch_size=32, image_size=(32,32), shuffle=True, )

My file directory is organized into classes with jpg files inside.

I don't know how to convert dataset file into and x_train and y_train to use in my model since model.fit doesn't take in the tf datasets.

I would appreciate some help in understanding how to take dataset and create x_train and y_train

Environment information
Windows 10,

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the keras.io documentation entry for image_dataset_from_directory and the model.fit entry point mentioned in the report. Determine whether the documentation clearly explains the expected dataset input and how it relates to x_train and y_train, then update the relevant guidance so the conversion workflow and completion criteria are unambiguous.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
data, machine-learning
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.