Professional Documents
Culture Documents
IM 6, English 12 AP
5/13/17
UsingAutoencoderstoclassifyAgeRelatedMacularDegeneration
Code:
import glob
import numpy as np
img_list = []
im = Image.open(filename)
im = im.crop((0,0,28,28))
img_list.append(im)
data = data.T
print(data.shape)
x = UpSampling2D((2, 2))(x)
x = UpSampling2D((2, 2))(x)
x = Convolution2D(64, 3, 3, activation='relu')(x)
x = UpSampling2D((2, 2))(x)
autoencoder.compile(optimizer='adadelta', loss='binary_crossentropy')
x_train = data[:(len(data)/2)]
x_test = data[len(data)/2:]
print np.shape(x_train)
print np.shape(x_test)
Jacob Chandran
IM 6, English 12 AP
5/13/17
autoencoder.fit(x_train, x_train,
nb_epoch=50,
batch_size=128,
shuffle=True,
validation_data=(x_test, x_test),
#callbacks=[TensorBoard(log_dir='/tmp/autoencoder')]
decoded_imgs = autoencoder.predict(x_test)
print np.shape(x_test[1])
#####Display images#####
n = 10
plt.figure(figsize=(20, 4))
for i in range(n):
# display original
ax = plt.subplot(2, n, i)
Jacob Chandran
IM 6, English 12 AP
5/13/17
#plt.imshow(x_test[i].reshape(28, 28))
plt.imshow(x_test[i].transpose(1,2,0))
plt.gray()
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)
# display reconstruction
ax = plt.subplot(2, n, i + n)
#plt.imshow(decoded_imgs[i].reshape(28, 28))
plt.imshow(decoded_imgs[i].transpose(1,2,0))
plt.gray()
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)
plt.show()
Explanation:
images into matrixes and then vectors which are useful for data analysis and image
takes an image, turns it into its matrix representation, flattens the matrix into a
vector, and then converts the data back to image. Unfortunately, some data is always
lost in the translation between the original image and the reconstructed image,
power is revealed when we recognize that images of diseases can be analyzed. This
There is a prevalent eye disease in older people called Age Related Macular
Degeneration (AMD) where white spots begin to form on the eye and limit the
ability of the eye to see. The issue is that only with early detection can this disease
be cured, however, there are not many detection systems for AMD. Using
autoencoders, at APL, we have build an autoencoder that, trained with the images of
the healthy eye, can recognize deviations from this norm. Basically, by compressing
images from their picture state down to a vector state, by mathematical formula,
the center of balance of all the healthy images can be calculated. After this, a
standard deviation can be determined so that any image vector outside of this
problem of detection, however, this code is just the foundation of this recognition
technology, and will also need to be converted into a user friendly interface through
an app for example. There are still many more steps that need to be taken for this
implementation, however the real power of this experiment is the idea the this kind
Along with AMD, in the lab, this research is also being applied to breast
cancer research. We have found ways to create artificial tissue and cancerous cysts
called phantoms. Using an ultrasound machine, we can take pictures of the cancer
just like it would be seen in a real person, and then analyze these images.
Ultrasound images are actually very noisy in that they create unclear pictures with
a lot of unrelated picture images. This is where autoencoders can be used. Even
though autoencoders are very prone to losing data, if they lose the right data in this
scenario, basically, all of the noise in the ultrasound image can be eliminated so that
it is easier to detect cancer in images. This is one case study of how losing data can
actually be beneficial to classification. Along with these two examples, breast cancer
and AMD, hopefully there will be many places to implement autoencoders so that
computer science can be used as a side by side tool that aids early detection in the
medical field.