In [1]:
import matplotlib.pyplot as plt
from utils import data_utils, train_utils
%matplotlib inline
import cv2
import numpy as np
from matplotlib import cm
from PIL import Image
from descartes.patch import PolygonPatch
from shapely import wkt
from shapely import affinity
import matplotlib

In [2]:
new_style = {'grid': False}
matplotlib.rc('axes', **new_style)

Test training input


In [4]:
train_input = train_utils.input_data(class_id=0, crop_size=144, crop_per_img=1, rotation=360, verbose=True, train=True)

In [6]:
img, label = train_inputd.next()


Loading training data: [                        ] 0%
utils/data_utils.py:786: RuntimeWarning: divide by zero encountered in divide
  (nir - image_r) / (nir + C1 * image_r - C2 * image_b + L))
Loading training data: [=                       ] 4%
Loading training data: [==                      ] 8%
Loading training data: [===                     ] 12%
Loading training data: [====                    ] 16%
Loading training data: [=====                   ] 20%
Loading training data: [======                  ] 25%
utils/data_utils.py:786: RuntimeWarning: invalid value encountered in divide
  (nir - image_r) / (nir + C1 * image_r - C2 * image_b + L))
Loading training data: [=======                 ] 29%
Loading training data: [========                ] 33%
Loading training data: [=========               ] 37%
Loading training data: [==========              ] 41%
Loading training data: [===========             ] 45%
Loading training data: [============            ] 50%
Loading training data: [=============           ] 54%
Loading training data: [==============          ] 58%
Loading training data: [===============         ] 62%
Loading training data: [================        ] 66%
Loading training data: [=================       ] 70%
Loading training data: [==================      ] 75%
Loading training data: [===================     ] 79%
Loading training data: [====================    ] 83%
Loading training data: [=====================   ] 87%
Loading training data: [======================  ] 91%
Loading training data: [======================= ] 95%
Loading training data: [========================] 100%

Labels are valid.
Image features are valid.

Rotation angle : 255(degree),  4.45(radian)
x_base 1944 for No. 6 image
y_base 408 for No. 6 image
x_base 2512 for No. 1 image
y_base 562 for No. 1 image
x_base 782 for No. 12 image
y_base 8 for No. 12 image
x_base 339 for No. 11 image
y_base 558 for No. 11 image
x_base 2310 for No. 9 image
y_base 2863 for No. 9 image
x_base 1453 for No. 3 image
y_base 2979 for No. 3 image
x_base 2297 for No. 5 image
y_base 1401 for No. 5 image
x_base 97 for No. 14 image
y_base 1268 for No. 14 image
x_base 2228 for No. 23 image
y_base 1942 for No. 23 image
x_base 1076 for No. 7 image
y_base 1292 for No. 7 image
x_base 2477 for No. 21 image
y_base 313 for No. 21 image
x_base 3033 for No. 0 image
y_base 2572 for No. 0 image
x_base 1967 for No. 4 image
y_base 3114 for No. 4 image
x_base 828 for No. 15 image
y_base 772 for No. 15 image
x_base 3017 for No. 8 image
y_base 825 for No. 8 image
x_base 1145 for No. 17 image
y_base 3067 for No. 17 image
x_base 2284 for No. 22 image
y_base 405 for No. 22 image
x_base 357 for No. 16 image
y_base 953 for No. 16 image
x_base 2317 for No. 2 image
y_base 945 for No. 2 image
x_base 1142 for No. 20 image
y_base 903 for No. 20 image
x_base 212 for No. 19 image
y_base 2744 for No. 19 image
x_base 569 for No. 18 image
y_base 83 for No. 18 image
x_base 324 for No. 13 image
y_base 290 for No. 13 image
x_base 64 for No. 24 image
y_base 1084 for No. 24 image
x_base 2631 for No. 10 image
y_base 2971 for No. 10 image

In [8]:
print img.shape, label.shape


(25, 144, 144, 16) (25, 144, 144)

In [10]:
ind = 0
fig, axs = plt.subplots(5,5, figsize=[20,20])
for i in range(5):
    for j in range(5):
        axs[i,j].imshow(data_utils.scale_percentile(img[ind, :,:,9:12]))
        ind = ind+1



In [11]:
ind = 0
fig, axs = plt.subplots(5,5, figsize=[20,20])
for i in range(5):
    for j in range(5):
        axs[i,j].imshow(label[ind, :, :], cmap=plt.cm.gray)
        ind = ind+1


Classes


In [7]:
data_utils.CLASSES


Out[7]:
{1: 'Bldg',
 2: 'Struct',
 3: 'Road',
 4: 'Track',
 5: 'Trees',
 6: 'Crops',
 7: 'Fast H2O',
 8: 'Slow H2O',
 9: 'Truck',
 10: 'Car'}

In [18]:
img_data = data_utils.ImageData(17)

In [19]:
# load data
img_data.load_image()
img_data.create_label()
img_data.create_train_feature()

In [20]:
img_data.visualize_image(plot_all=True)


1: Bldg 		count = 1962
2: Struct 		count = 3201
3: Road 		count = 1
4: Track 		count = 33
5: Trees 		count = 1452
6: Crops 		count = 20
7: Fast H2O 		count = 0
8: Slow H2O 		count = 6
9: Truck 		count = 9
10: Car 		count = 548

In [21]:
img_data.visualize_label()


1: Bldg 		count = 1962
2: Struct 		count = 3201
3: Road 		count = 1
4: Track 		count = 33
5: Trees 		count = 1452
6: Crops 		count = 20
7: Fast H2O 		count = 0
8: Slow H2O 		count = 6
9: Truck 		count = 9
10: Car 		count = 548

Stats of training data:


In [23]:
data_utils.plot_bar_stats()


Collecting class stats [========================] 100%

Total area stats


In [24]:
data_utils.plot_stats(title='Total area', value='TotalArea')


Collecting class stats [========================] 100%

Counts of instances


In [25]:
data_utils.plot_stats(title='Counts', value='Counts')


Collecting class stats [========================] 100%