나는 convnet을 훈련하기 위해 아주 기본적인 이미지 확대를하고 있는데, 매우 느리다. 파이썬에서 이미지를 열고, 뒤집고, 닫는 더 빠른 방법에 대한 조언을 누군가가 가지고 있는지 궁금합니다. 통과 할 이미지는 약 100,000 개이며 몇 시간이 걸립니다.느린 이미지 열기 python, 속도 향상 권장?
print 'Example of image in train.txt: ' + image_file[0]
print 'Example of annotation in train.txt: ' + annot_file[0]
train_file.close()
for i in range(len(image_file)):
temp_image = imread(image_file[i])
temp_annot = imread(annot_file[i])
temp_image_name = image_file[i][:-4] + '_augmented_lrflip.png'
temp_annot_name = annot_file[i][:-4] + '_augmented_lrflip.png'
imsave(temp_image_name,np.fliplr(temp_image))
imsave(temp_annot_name,np.fliplr(temp_annot))
image_file.append(temp_image_name)
annot_file.append(temp_annot_name)
temp_image_name = image_file[i][:-4] + '_augmented_lr_ud_flip.png'
temp_annot_name = annot_file[i][:-4] + '_augmented_lr_ud_flip.png'
imsave(temp_image_name,np.fliplr(np.flipud(temp_image)))
imsave(temp_annot_name,np.fliplr(np.flipud(temp_annot)))
image_file.append(temp_image_name)
annot_file.append(temp_annot_name)
temp_image_name = image_file[i][:-4] + '_augmented_udflip.png'
temp_annot_name = annot_file[i][:-4] + '_augmented_udflip.png'
imsave(temp_image_name,np.flipud(temp_image))
imsave(temp_annot_name,np.flipud(temp_annot))
image_file.append(temp_image_name)
annot_file.append(temp_annot_name)
train_file_mod = open('train_augmented.txt', 'wb')
for i in range(len(image_file)):
train_file_mod.write(image_file[i] + ' ' + annot_file[i] + '\n')
train_file_mod.close()
대신에 cv2.imwrite를 사용했는데 훨씬 빨랐습니다. 내 문제를 해결 한 것 같았다. 나는 나중에 사용을 위해 케라를 볼 것이다. –