Hi, I'm trying to do "random crop" using tf.image.random,but jupyter notebook keeps showing me an error: "could notbroadcast input array from shape (180,280,3) into shape(299,299,3)". When I'm trying to increase size value (second lineof the code), it's telling me "Expected 'tf.Tensor(False, shape=(),dtype=bool)' to be true. Summarized data: b'Need value.shape >=size, got ' 299, 299, 3, 350, 300, 3"
def crop(image): image = tf.image.random_crop(value=image,size=[180,180,3])
#size = [crop_height, crop_width, 3] return image
#Geometric transformationsdatagen = ImageDataGenerator( rescale=1./255, rotation_range=40, width_shift_range=0.2, height_shift_range=0.2, zoom_range=0.2, preprocessing_function=crop, )
# Load an image into PIL formatimg_path = 'Sample_circles.png'img = tf.keras.utils.load_img(img_path, target_size=(299, 299,3))
# Generate distorted imagesimages = [img]img_arr = tf.keras.utils.img_to_array(img)img_arr = img_arr.reshape((1,) + img_arr.shape)for batch in datagen.flow(img_arr, batch_size=1): images.append( tf.keras.utils.array_to_img(batch[0])) if len(images) >= 4: #Change number ofoutputs break
# Show f, xyarr = plt.subplots(2,2)xyarr[0,0].imshow(images[0])xyarr[0,1].imshow(images[1])xyarr[1,0].imshow(images[2])xyarr[1,1].imshow(images[3])plt.show()
Hi, I'm trying to do "random crop" using tf.image.random, but jupyter notebook keeps showing me an error: "could not bro
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am