March 5, 2019No Comments

Image Feature Extraction

Based on image-search.ipynb and image-tsne.ipynb

  • Solve the alpha channel issue for feature extraction; directly pull images from the API
  • "This is due to the fact that eps does not know about transparency and the default background color for the rasterization was (0, 0, 0, 0) (black which is fully transparent)." --- continuing error in analysis + expanding features
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
  • Test with more than thousands images (max 50 per a call)
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)

© 2024 Alice Hee Gyung Sun

Back to top Arrow