## caffe2 공부를 위해 caffe2 Tutorials을 보고 하고 있습니다.

알려주는 python 소스는 일부분만 표시되어있어 

안좋은 머리로 나머지 소스를 붙여넣어 수행되는 소스를 기록하였습니다.



import skimage

import skimage.io as io

import skimage.transform

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"

IMAGE_LOCATION = "https://upload.wikimedia.org/wikipedia/commons/e/e1/Ananas.jpg"


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


input_height, input_width = 224, 224


print("Original image shape:" + str(img.shape) + " and remember it should be in H, W, C!")

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

aspect = img.shape[1]/float(img.shape[0])

print("Orginal aspect ratio: " + str(aspect))

if(aspect>1):

    # landscape orientation - wide image

    res = int(aspect * input_height)

    imgScaled = skimage.transform.resize(img, (input_width, res))

if(aspect<1):

    # portrait orientation - tall image

    res = int(input_width/aspect)

    imgScaled = skimage.transform.resize(img, (res, input_height))

if(aspect == 1):

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

pyplot.figure()

pyplot.imshow(imgScaled)

pyplot.axis('on')

pyplot.title('Rescaled image\nbigsun84')

print("New image shape:" + str(imgScaled.shape) + " in HWC")

pyplot.show()


 




블로그 이미지

§§

내 주머니속 작은 수첩

,