DORI
DORI

Reputation: 1

module 'tensorflow' has no attribute 'read_file'

I ran the below code:

train_df , valid_df  = train_test_split (full_food_df, 
                                        test_size = 0.25, 
                                        random_state = 2018,
                                        stratify = full_food_df['category'])


valid_idg = tf_augmentor(out_size = IMG_SIZE, color_mode = 'rgb', 
                         crop_probability=0.0, 
                         horizontal_flip = False, 
                        vertical_flip = False,
                        random_brightness = False,
                        random_contrast = False,
                        random_saturation = False,
                       random_hue = False,
                       rotation_range = 0,
                       batch_size = batch_size)

valid_gen = flow_from_dataframe(valid_idg, valid_df, 
                                path_col = 'path',
                                y_col = 'cat_vec')# we can use much larger batches for evaluation


t_x, t_y = next(valid_gen)
fig, m_axs = plt.subplots(2, 4, figsize = (16, 8))
for (c_x, c_y, c_ax) in zip(x, y, m_axs.flatten()):
     c_ax.imshow(np.clip(c_x+127, 0, 255).astype(np.uint8))
     c_ax.set_title('{}'.format(food_cat.classes_[np.argmax(c_y, -1)]))
     c_ax.axis('off')

I have error : module 'tensorflow' has no attribute 'read_file'

in line: t_x, t_y = next(valid_gen)

Can anyone help me?

Upvotes: 0

Views: 4218

Answers (1)

Happy Nkanta Monday
Happy Nkanta Monday

Reputation: 429

The function has been moved into the tensorflow.io module. You should change your code like it was done below:

import tensorflow as tf

img_raw = tf.io.read_file(img_path)

print(repr(img_raw)[:100]+"…")

Upvotes: 1

Related Questions