본문 바로가기

지식생활/A.I.

카페2 튜토리얼 Image Pre-Processing (Sizing)


## caffe2 Tutorials Sizing 부분을 테스트하고

정상적으로 수행되는 소스를 기록하였습니다.


import skimage

import skimage.io as io

import skimage.transform as resize

import numpy as np

import matplotlib.pyplot as pyplot


IMAGE_LOCATION = "https://cdn.pixabay.com/photo/2015/02/10/21/28/flower-631765_1280.jpg"


## 비교 차원에서 원본사진 출력

img = skimage.img_as_float(skimage.io.imread(IMAGE_LOCATION)).astype(np.float32)

pyplot.figure()

pyplot.imshow(img)

pyplot.axis('on')

pyplot.title('Original\nbig-sun.tistory.com')

pyplot.show()


## 200x200 으로 사이즈 변경

input_height, input_width = 200, 200

print("Model's input shape is %dx%d") % (input_height, input_width)


img200 = skimage.transform.resize(img, (input_height, input_width))

pyplot.figure()

pyplot.imshow(img200)

pyplot.axis('on')

pyplot.title('Resized image to 200x200\nbig-sun.tistory.com.')

print("New image shape: " + str(img200.shape))

pyplot.show()