I want to save my preprocessed data in the kaggle output directory. The problem is, I want to save using the same name as the input file. so in my code, I have cropped and resized the image and now don't know how to save the cropped and resized images. here is my code.
path ='../input/137x236'
train_data_path = os.path.join(path, '137x236')
images = os.listdir(train_data_path)
image_len = len(images)
images1 = images[1::1500]
h=64
w=64
x_train = np.zeros((len(images1), h, w,3), dtype=np.uint8)
index = 0
for x in images1:
path = os.path.join(train_data_path, x)
image = imread(path)
image = crop_image(image, tol=82)
image = resize(image, (h, w,3), mode='constant', preserve_range=True)
#image.resize(64,64)
x_train[index] = image
index += 1
filename = 'path'
cv2.imwrite(path, x_train)
#print(x_train.shape)
#x_train = x_train / 255
#x_train = x_train.astype('float32')
imshow(x_train[5])
#print(x_train.dtype)
use something like this: .zip-folder --auto-root --outfile /kaggle/working/dataset.zip /kaggle/working/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.