Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
236 views
in Technique[技术] by (71.8m points)

keras - Is there any way to resize an images present in an array of images

i have an image data present in format of (1449,640,480,3) i want to resize my images before giving it to CNN. i can resize them by extracting every single image and then group them in an array but it would take alot of time and RAM. is there any way (using tensorflow, or keras or any other library ) to resize it.

question from:https://stackoverflow.com/questions/65880140/is-there-any-way-to-resize-an-images-present-in-an-array-of-images

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
import keras
from keras.datasets import mnist
(train_images, train_labels), (test_images, test_labels) = mnist.load_data()

I have just loaded the mnist library for giving example. If we see the shape of the train_images.

train_images.shape
> (60000, 28, 28)

So its a 3D array where we have 60000 images with 28×28 shaped images. We can convert this 28×28 2D images to 1D images of 784(28×28).

train_images = train_images.reshape((60000, 28 * 28))
train_images.shape
> (60000, 784)

Hope it helped.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...