import cv2
import tensorflow as tf
from tensorflow.keras import layers
import matplotlib.pyplot as plt
img = cv2.imread(r"C:\Users\admin\Pictures\res.png")
h,w,c = img.shape
H,W = int(h*1),int(w*1)
resize_and_rescale = tf.keras.Sequential([
layers.experimental.preprocessing.Resizing(H, W),
layers.experimental.preprocessing.Rescaling(1./255)
])
result = resize_and_rescale(img)
_ = plt.imshow(result)
plt.show()
import cv2
import tensorflow as tf
from tensorflow.keras import layers
import matplotlib.pyplot as plt
img = cv2.imread(r"C:\Users\admin\Pictures\res.png")
print(img.shape[0],img.shape[1])
data_augmentation = tf.keras.Sequential([
layers.experimental.preprocessing.RandomFlip("horizontal_and_vertical"),
layers.experimental.preprocessing.RandomRotation(0.2),
])
# Add the image to a batch
image = tf.expand_dims(img, 0)
plt.figure(figsize=(10,10))
for i in range(16):
augmented_image = data_augmentation(image)
# ax = plt.subplot(4, 4, i + 1)
plt.imshow(augmented_image[0])
# plt.axis("off")
plt.savefig("".join([str(i),".jpg"]))
plt.show()