Based on image-search.ipynb and image-tsne.ipynb
def load_image(path):
img = Image.open(path)
img = scipy.misc.imresize(np.array(img), (224, 224), interp='bicubic')
img[:,:,0] = 255.0-img[:,:,3]
img[:,:,1] = 255.0-img[:,:,3]
img[:,:,2] = 255.0-img[:,:,3]
img = img[:,:,:3]
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
return img, x
<ipython-input-22-6fd16072f6c2> in load_image(path)
8 img = Image.open(path)
9 img = scipy.misc.imresize(np.array(img), (224, 224), interp='bicubic')
---> 10 img[:,:,0] = 255.0-img[:,:,3]
11 img[:,:,1] = 255.0-img[:,:,3]
12 img[:,:,2] = 255.0-img[:,:,3]
IndexError: index 3 is out of bounds for axis 2 with size 3
auth = OAuth1("API KEY", "API KEY2")
endpoint = "https://api.thenounproject.com/icons/{term}?page=2"
response = requests.get(endpoint, auth=auth)
with open('./bicycle-p2.json', 'w') as results_file:
json.dump(response.json(), results_file)
Using a pre-trained model in Keras, e.g., VGG, to extract the feature of a given image;
© 2024 Alice Hee Gyung Sun