In [1]:
!pip freeze
In [2]:
%pylab
In [3]:
%matplotlib inline
In [4]:
cd ..
In [5]:
cd ../neukrill-net-work
In [6]:
import sys
import numpy as np
import skimage.io
In [7]:
import imp
In [8]:
import neukrill_net.utils as utils
import neukrill_net.image_processing as image_processing
import neukrill_net.augment as augment
In [9]:
from IPython.display import display
from IPython.display import Image
from IPython.display import HTML
In [10]:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
In [11]:
img = skimage.io.imread('data/train/acantharia_protist/100224.jpg')
In [12]:
type(img)
Out[12]:
In [13]:
img.shape
Out[13]:
In [14]:
imgplot = plt.imshow(img)
imgplot.set_cmap('gray')
In [15]:
augImg = image_processing.shear_image(img, -10)
iplot = plt.imshow(augImg)
iplot.set_cmap('gray')
show()
In [16]:
augFunc = augment.RandomAugment()
imgplot = plt.imshow(augFunc(img))
imgplot.set_cmap('gray')
In [17]:
reload(image_processing)
reload(augment)
Out[17]:
In [18]:
img2 = image_processing.padcrop_image(img,3,0.1)
imgplot = plt.imshow(img2)
imgplot.set_cmap('gray')
In [19]:
augFunc = augment.RandomAugment(units='float64',rotate=-1,rotate_is_resizable=False,shunt=[-0.05,0,0.05])
In [20]:
imgplot = plt.imshow(augFunc(img))
imgplot.set_cmap('gray')
In [21]:
augFunc = augment.RandomAugment(units='float64',rotate=-1,rotate_is_resizable=False,flip=True,shear=20,shunt=0.075)
In [22]:
imgplot = plt.imshow(augFunc(img))
imgplot.set_cmap('gray')
In [23]:
augFunc = augment.RandomAugment(units='float64',shear=20)
In [24]:
imgplot = plt.imshow(augFunc(img))
imgplot.set_cmap('gray')
In [25]:
img2 = image_processing.dynamic_shape_fix(img, (128,128), (0.2,0.9))
imgplot = plt.imshow(img2)
imgplot.set_cmap('gray')
In [26]:
reload(augment)
reload(image_processing)
Out[26]:
In [27]:
augFunc = augment.RandomAugment(units='float64',shear=5,rotate=-1,scale=0.1,dynamic_shapefix=1,shape=(128,128))
In [28]:
imgplot = plt.imshow(augFunc(img))
imgplot.set_cmap('gray')
In [29]:
augFunc = augment.RandomAugment(units='float64',dynamic_shapefix=1,shape=(80,80),scale=[0.5,1,2])
In [30]:
imgplot = plt.imshow(augFunc(img))
imgplot.set_cmap('gray')
In [31]:
augFunc = augment.RandomAugment(units='float64',shear=5,rotate=-1,scale=0.1,resize=(128,128))
In [32]:
imgplot = plt.imshow(augFunc(img))
imgplot.set_cmap('gray')
In [33]:
augFunc2 = augment.ParallelRandomAugment([{'resize':(30,30)}, {'shape':(30,30),'dynamic_shapefix':1}],
flip=1, shear=5, rotate=-1, scale=0.1, scale_asym=0.04, noise=0.0001, shunt=0.05)
In [68]:
im1,im2 = augFunc2(img)
print im1.shape
print im2.shape
imgplot = plt.imshow(im1)
imgplot.set_cmap('gray')
show()
imgplot = plt.imshow(im2)
imgplot.set_cmap('gray')
show()
In [69]:
settings = utils.Settings('settings.json')
In [71]:
X,y = utils.load_rawdata(settings.image_fnames, classes=settings.classes, verbose=False)
In [276]:
augFunc = augment.RandomAugment(units='float64',
flip=1, shear=5, rotate=-1, scale=0.075, scale_asym=0.02, resize=(48,48))
In [277]:
rng = np.random.RandomState(42)
In [285]:
index = rng.random_integers(0, len(X)-1)
imgplot = plt.imshow(image_processing.resize_image(X[index-1],(48,48)))
imgplot.set_cmap('gray')
plt.title(y[index-1])
show()
imgplot = plt.imshow(augFunc(X[index-1]))
imgplot.set_cmap('gray')
show()
imgplot = plt.imshow(image_processing.resize_image(X[index],(48,48)))
imgplot.set_cmap('gray')
plt.title(y[index])
show()
imgplot = plt.imshow(augFunc(X[index]))
imgplot.set_cmap('gray')
show()
imgplot = plt.imshow(image_processing.resize_image(X[index+1],(48,48)))
imgplot.set_cmap('gray')
plt.title(y[index+1])
show()
imgplot = plt.imshow(augFunc(X[index+1]))
imgplot.set_cmap('gray')
show()
In [239]:
augFunc = augment.RandomAugment(units='float64',
rotate=[10, 350], resize=(48,48))
In [254]:
imgplot = plt.imshow(augFunc(img))
imgplot.set_cmap('gray')
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: