Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'tensorflow_core._api.v2.image' has no attribute 'resize_images'

I want to resize images from 28*28 to 32*32,used tf.image.resize_images(x_train, (32, 32)).It returns AttributeError: module 'tensorflow_core._api.v2.image' has no attribute 'resize_images'.The version of tersorflow is 2.0.0. How can I fix it?

like image 215
Bigkfish Avatar asked Mar 31 '20 10:03

Bigkfish


3 Answers

It should be tf.image.resize See the updated doc https://www.tensorflow.org/api_docs/python/tf/image/resize

like image 110
Zabir Al Nazi Avatar answered Oct 21 '22 16:10

Zabir Al Nazi


  1. The problem The tf.image.resize_image function has not been support longer and when you execute the code like below:
import tensorflow as tf

img_final = tf.image.resize_images(img_tensor, [192, 192])

You get the following exception:

AttributeError: module 'tensorflow._api.v2.image' has no attribute 'resize_images'

  1. The solution The function has been renamed into resize. You should change your code like it was done below:
import tensorflow as tf

import tensorflow as tf

img_final = tf.image.resize(img_tensor, [192, 192])

For more info please check here: https://www.google.com/amp/s/better-coding.com/solved-tensorflow-attributeerror-module-tensorflow-_api-v2-image-has-no-attribute-resize_images/amp/

like image 4
BrigaDella Avatar answered Oct 21 '22 16:10

BrigaDella


tf.image.resize(trainX, size=(32,32))

More info on https://www.tensorflow.org/api_docs/python/tf/image/resize

Note that trainX should be a 4D or 3D tensor

like image 1
Tarun Avatar answered Oct 21 '22 15:10

Tarun