Vorhersagen mit trainiertem CNN Modell und Auswertung


In [1]:
import warnings
warnings.filterwarnings('ignore')

In [2]:
%matplotlib inline
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [3]:
import matplotlib.pylab as plt
import numpy as np

In [4]:
from distutils.version import StrictVersion

In [5]:
import sklearn
print(sklearn.__version__)

assert StrictVersion(sklearn.__version__ ) >= StrictVersion('0.18.1')


0.19.0

In [6]:
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)
print(tf.__version__)

assert StrictVersion(tf.__version__) >= StrictVersion('1.2.1')


1.2.1

In [7]:
import keras
print(keras.__version__)

assert StrictVersion(keras.__version__) >= StrictVersion('2.0.6')


Using TensorFlow backend.
2.0.8

In [8]:
# We need keras 2.0.6 or later as this is the version we created the model with
# !pip install keras --upgrade

Laden realistischer Daten


In [9]:
!curl -O https://raw.githubusercontent.com/DJCordhose/speed-limit-signs/master/data/real-world.zip
from zipfile import ZipFile
zip = ZipFile(r'real-world.zip')
zip.extractall('.')


  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1203k  100 1203k    0     0  3579k      0 --:--:-- --:--:-- --:--:-- 4039k

In [10]:
!ls -l real-world


total 0
drwxrwxrwx 0 root root 512 Sep 26 16:17 0
drwxrwxrwx 0 root root 512 Sep 26 16:17 1
drwxrwxrwx 0 root root 512 Sep 26 16:17 2
drwxrwxrwx 0 root root 512 Sep 26 16:17 3
drwxrwxrwx 0 root root 512 Sep 26 16:17 4
drwxrwxrwx 0 root root 512 Sep 26 16:17 5

In [11]:
import os
import skimage.data
import skimage.transform

def load_data(data_dir):
    # Get all subdirectories of data_dir. Each represents a label.
    directories = [d for d in os.listdir(data_dir) 
                   if os.path.isdir(os.path.join(data_dir, d))]
    # Loop through the label directories and collect the data in
    # two lists, labels and images.
    labels = []
    images = []
    all_file_names = []
    for d in directories:
        label_dir = os.path.join(data_dir, d)
        file_names = [os.path.join(label_dir, f) 
                      for f in os.listdir(label_dir)]
        # For each label, load it's images and add them to the images list.
        # And add the label number (i.e. directory name) to the labels list.
        for f in file_names:
            images.append(skimage.data.imread(f))
            labels.append(int(d))
            all_file_names.append(f)
    # Resize images
    images64 = [skimage.transform.resize(image, (64, 64))
                for image in images]
    return images64, labels, all_file_names

In [12]:
# Load datasets.
ROOT_PATH = "./"
data_dir = os.path.join(ROOT_PATH, "real-world")

images, labels, file_names = load_data(data_dir)

In [13]:
import matplotlib
import matplotlib.pyplot as plt

def display_images_and_labels(images, labels):
    plt.figure(figsize=(15, 15))
    i = 0
    for label in labels:
        # Pick the first image for each label.
        image = images[i]
        plt.subplot(4, 4, i + 1)  # A grid of 8 rows x 8 columns
        plt.axis('off')
        plt.title("{0}".format(label))
        i += 1
        plt.imshow(image)
    plt.show()

In [14]:
display_images_and_labels(images, file_names)


Modell laden


In [15]:
!curl -O https://transfer.sh/M5SOs/conv-vgg.hdf5


  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 54.8M  100 54.8M    0     0  1841k      0  0:00:30  0:00:30 --:--:-- 6681k:06:10 2535k

In [16]:
from keras.models import load_model
model = load_model('conv-vgg.hdf5')

In [17]:
!ls -lh


total 30G
drwxrwxrwx 0 root root  512 Sep 25 18:10 augmented-signs
-rwxrwxrwx 1 root root 136K Sep 25 18:12 cnn-augmentation.ipynb
-rwxrwxrwx 1 root root 1.6M Sep 25 14:57 cnn-comparing-all-models.ipynb
-rwxrwxrwx 1 root root 380K Sep 25 15:46 cnn-intro.ipynb
-rwxrwxrwx 1 root root 1.3M Sep 25 14:57 cnn-prediction.ipynb
-rwxrwxrwx 1 root root 198K Sep 25 18:14 cnn-train-augmented.ipynb
-rwxrwxrwx 1 root root  55M Sep 26 16:18 conv-vgg.hdf5
drwxrwxrwx 0 root root  512 Sep 25 18:08 generated
drwxrwxrwx 0 root root  512 Sep 25 18:06 __MACOSX
-rwxrwxrwx 1 root root 113K Sep 25 17:14 nn-intro.ipynb
-rwxrwxrwx 1 root root   63 Sep 25 14:57 README.html
drwxrwxrwx 0 root root  512 Sep 26 16:17 real-world
-rwxrwxrwx 1 root root 1.2M Sep 26 16:17 real-world.zip
-rwxrwxrwx 1 root root   36 Aug  3 21:15 sample_iris.json
drwxrwxrwx 0 root root  512 Sep 25 18:06 speed-limit-signs
-rwxrwxrwx 1 root root 6.9K Sep 25 18:11 workshop.ipynb

In [18]:
BATCH_SIZE = 500

y = np.array(labels)
X = np.array(images)
from keras.utils.np_utils import to_categorical

num_categories = 6

y = to_categorical(y, num_categories)
loss, accuracy = model.evaluate(X, y, batch_size=BATCH_SIZE)
loss, accuracy


15/15 [==============================] - 1s
Out[18]:
(5.5410223007202148, 0.60000002384185791)

In [19]:
import skimage.transform
def predict_single(image):
    # normalize
    X_sample = np.array([image])
    prediction = model.predict(X_sample)
    predicted_category = np.argmax(prediction, axis=1)
    return predicted_category, prediction

In [20]:
# Display the predictions and the ground truth visually.
def display_prediction (images, true_labels, predicted_labels):
    fig = plt.figure(figsize=(10, 10))
    for i in range(len(true_labels)):
        truth = true_labels[i]
        prediction = predicted_labels[i]
        plt.subplot(6, 3,1+i)
        plt.axis('off')
        color='green' if truth == prediction else 'red'
        plt.text(80, 10, "Truth:        {0}\nPrediction: {1}".format(truth, prediction), 
                 fontsize=12, color=color)
        plt.imshow(images[i])

In [21]:
X_sample = np.array(images)
prediction = model.predict(X_sample)
predicted_categories = np.argmax(prediction, axis=1)
ground_truth = np.array(labels)
display_prediction(images, ground_truth, predicted_categories)


Bewertung: 9 von 15 richtig, 60% Accracy

Gar nicht mal so schlecht, besonders weil wir Translations Invariance nie trainiert haben

Aber

  • no translation invariance, signes have to be at center
  • not robust against background
  • false positives (70 is address sign, not traffic sign)
  • not robust against unclear signes (50 looks like 30)
  • not robust against distortions (100, 80)

Next steps might be to

  • artifically expand training set by applying transformations that match missing robustness
  • introduce category 'no speed limit sign'
  • translation invariance added in training material
  • try other architectures

Wir gucken mal unter die Haube

Bisher haben wir das Modell als Blackbox angesehen, wir haben gar keine Ahnung, was da eigentlich erkannt wird

Warum wird das mit der 80 nichts?

Nach der ersten Conv Schicht

Nach einer mittleren Conv Schicht

Nach der letzten Conv Schicht


In [28]:
!rm -r tmp
!mkdir tmp

In [ ]:
# Only works locally

# https://github.com/keplr-io/quiver

# create a tmp dir in the local directory this notebook runs in, otherwise quiver will fail (and won't tell you why)
# !mkdir tmp

# change image_class to feed in different classes
image_class = '3'

# https://github.com/keplr-io/quiver
from quiver_engine import server
server.launch(model, input_folder=data_dir+'/'+image_class, port=7000)

# open at http://localhost:7000/
# interrupt kernel to return control to notebook


Starting webserver from: /home/olli/anaconda3/lib/python3.6/site-packages/quiver_engine
::1 - - [2017-09-26 16:29:56] "GET /model HTTP/1.1" 200 13996 0.010899
::1 - - [2017-09-26 16:29:56] "GET /inputs HTTP/1.1" 200 208 0.002569
[2017-09-26 16:30:03,196] ERROR in app: Exception on /predict/50-berlin.jpg [GET]
Traceback (most recent call last):
  File "/home/olli/anaconda3/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/olli/anaconda3/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/olli/anaconda3/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/olli/anaconda3/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/olli/anaconda3/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/olli/anaconda3/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/olli/anaconda3/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/olli/anaconda3/lib/python3.6/site-packages/quiver_engine/server.py", line 127, in get_prediction
    input_img = load_img(input_path, single_input_shape, grayscale=is_grayscale)
  File "/home/olli/anaconda3/lib/python3.6/site-packages/quiver_engine/util.py", line 27, in load_img
    img = image.load_img(input_path, target_size=target_shape, grayscale=grayscale)
  File "/home/olli/anaconda3/lib/python3.6/site-packages/keras/preprocessing/image.py", line 322, in load_img
    img = pil_image.open(path)
  File "/home/olli/anaconda3/lib/python3.6/site-packages/PIL/Image.py", line 2477, in open
    fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: '50-berlin.jpg'
::1 - - [2017-09-26 16:30:03] "GET /predict/50-berlin.jpg HTTP/1.1" 500 444 0.008199
::1 - - [2017-09-26 16:30:04] "GET /layer/conv2d_16/50-berlin.jpg HTTP/1.1" 200 4898 1.291866
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_0_50-berlin.jpg.png HTTP/1.1" 200 619 0.006595
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_5_50-berlin.jpg.png HTTP/1.1" 200 621 0.005497
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_4_50-berlin.jpg.png HTTP/1.1" 200 529 0.006340
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_3_50-berlin.jpg.png HTTP/1.1" 200 628 0.004404
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_2_50-berlin.jpg.png HTTP/1.1" 200 712 0.005278
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_1_50-berlin.jpg.png HTTP/1.1" 200 570 0.005942
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_7_50-berlin.jpg.png HTTP/1.1" 200 684 0.003594
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_8_50-berlin.jpg.png HTTP/1.1" 200 803 0.007832
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_9_50-berlin.jpg.png HTTP/1.1" 200 679 0.004540
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_6_50-berlin.jpg.png HTTP/1.1" 200 716 0.010282
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_26_50-berlin.jpg.png HTTP/1.1" 200 513 0.011390
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_41_50-berlin.jpg.png HTTP/1.1" 200 1006 0.008890
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_37_50-berlin.jpg.png HTTP/1.1" 200 482 0.005187
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_10_50-berlin.jpg.png HTTP/1.1" 200 548 0.009434
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_27_50-berlin.jpg.png HTTP/1.1" 200 937 0.003961
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_29_50-berlin.jpg.png HTTP/1.1" 200 429 0.006470
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_21_50-berlin.jpg.png HTTP/1.1" 200 496 0.005661
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_12_50-berlin.jpg.png HTTP/1.1" 200 524 0.005369
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_15_50-berlin.jpg.png HTTP/1.1" 200 603 0.009305
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_39_50-berlin.jpg.png HTTP/1.1" 200 628 0.015300
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_14_50-berlin.jpg.png HTTP/1.1" 200 597 0.020799
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_28_50-berlin.jpg.png HTTP/1.1" 200 551 0.010292
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_25_50-berlin.jpg.png HTTP/1.1" 200 663 0.010390
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_17_50-berlin.jpg.png HTTP/1.1" 200 498 0.022898
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_33_50-berlin.jpg.png HTTP/1.1" 200 1252 0.009659
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_34_50-berlin.jpg.png HTTP/1.1" 200 436 0.008735
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_47_50-berlin.jpg.png HTTP/1.1" 200 1266 0.007806
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_43_50-berlin.jpg.png HTTP/1.1" 200 675 0.008441
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_48_50-berlin.jpg.png HTTP/1.1" 200 678 0.014840
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_20_50-berlin.jpg.png HTTP/1.1" 200 520 0.014324
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_16_50-berlin.jpg.png HTTP/1.1" 200 1234 0.007585
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_35_50-berlin.jpg.png HTTP/1.1" 200 638 0.023191
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_36_50-berlin.jpg.png HTTP/1.1" 200 645 0.007652
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_11_50-berlin.jpg.png HTTP/1.1" 200 1206 0.017168
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_38_50-berlin.jpg.png HTTP/1.1" 200 580 0.025703
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_13_50-berlin.jpg.png HTTP/1.1" 200 662 0.016522
::1 - - [2017-09-26 16:30:04] "GET /temp-file/conv2d_16_40_50-berlin.jpg.png HTTP/1.1" 200 689 0.010126
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_22_50-berlin.jpg.png HTTP/1.1" 200 413 0.034880
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_24_50-berlin.jpg.png HTTP/1.1" 200 408 0.002696
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_30_50-berlin.jpg.png HTTP/1.1" 200 650 0.010191
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_31_50-berlin.jpg.png HTTP/1.1" 200 1236 0.013618
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_44_50-berlin.jpg.png HTTP/1.1" 200 405 0.009611
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_46_50-berlin.jpg.png HTTP/1.1" 200 608 0.013726
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_19_50-berlin.jpg.png HTTP/1.1" 200 762 0.010548
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_32_50-berlin.jpg.png HTTP/1.1" 200 527 0.007525
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_23_50-berlin.jpg.png HTTP/1.1" 200 719 0.024063
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_51_50-berlin.jpg.png HTTP/1.1" 200 462 0.012776
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_45_50-berlin.jpg.png HTTP/1.1" 200 466 0.027745
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_53_50-berlin.jpg.png HTTP/1.1" 200 1186 0.020664
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_54_50-berlin.jpg.png HTTP/1.1" 200 610 0.016805
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_42_50-berlin.jpg.png HTTP/1.1" 200 1202 0.005319
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_49_50-berlin.jpg.png HTTP/1.1" 200 673 0.009354
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_57_50-berlin.jpg.png HTTP/1.1" 200 589 0.015478
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_58_50-berlin.jpg.png HTTP/1.1" 200 547 0.009457
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_59_50-berlin.jpg.png HTTP/1.1" 200 551 0.009845
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_60_50-berlin.jpg.png HTTP/1.1" 200 1229 0.007430
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_18_50-berlin.jpg.png HTTP/1.1" 200 703 0.008080
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_62_50-berlin.jpg.png HTTP/1.1" 200 781 0.008824
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_63_50-berlin.jpg.png HTTP/1.1" 200 536 0.013531
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_64_50-berlin.jpg.png HTTP/1.1" 200 425 0.007181
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_52_50-berlin.jpg.png HTTP/1.1" 200 641 0.008226
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_66_50-berlin.jpg.png HTTP/1.1" 200 645 0.012090
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_67_50-berlin.jpg.png HTTP/1.1" 200 475 0.011436
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_68_50-berlin.jpg.png HTTP/1.1" 200 708 0.009028
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_55_50-berlin.jpg.png HTTP/1.1" 200 508 0.008458
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_56_50-berlin.jpg.png HTTP/1.1" 200 575 0.005262
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_61_50-berlin.jpg.png HTTP/1.1" 200 539 0.008910
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_50_50-berlin.jpg.png HTTP/1.1" 200 1233 0.004033
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_69_50-berlin.jpg.png HTTP/1.1" 200 570 0.009770
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_74_50-berlin.jpg.png HTTP/1.1" 200 567 0.009659
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_70_50-berlin.jpg.png HTTP/1.1" 200 1225 0.005042
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_71_50-berlin.jpg.png HTTP/1.1" 200 563 0.008081
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_72_50-berlin.jpg.png HTTP/1.1" 200 686 0.006682
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_65_50-berlin.jpg.png HTTP/1.1" 200 636 0.006596
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_79_50-berlin.jpg.png HTTP/1.1" 200 691 0.008090
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_75_50-berlin.jpg.png HTTP/1.1" 200 630 0.004465
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_76_50-berlin.jpg.png HTTP/1.1" 200 473 0.010201
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_77_50-berlin.jpg.png HTTP/1.1" 200 527 0.002541
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_78_50-berlin.jpg.png HTTP/1.1" 200 1201 0.006601
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_73_50-berlin.jpg.png HTTP/1.1" 200 675 0.012157
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_85_50-berlin.jpg.png HTTP/1.1" 200 643 0.007346
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_86_50-berlin.jpg.png HTTP/1.1" 200 625 0.007982
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_81_50-berlin.jpg.png HTTP/1.1" 200 580 0.004742
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_82_50-berlin.jpg.png HTTP/1.1" 200 500 0.009901
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_89_50-berlin.jpg.png HTTP/1.1" 200 735 0.012932
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_90_50-berlin.jpg.png HTTP/1.1" 200 544 0.005133
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_84_50-berlin.jpg.png HTTP/1.1" 200 524 0.007265
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_83_50-berlin.jpg.png HTTP/1.1" 200 701 0.013067
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_93_50-berlin.jpg.png HTTP/1.1" 200 716 0.005766
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_80_50-berlin.jpg.png HTTP/1.1" 200 678 0.007655
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_88_50-berlin.jpg.png HTTP/1.1" 200 1235 0.008961
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_96_50-berlin.jpg.png HTTP/1.1" 200 615 0.017685
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_97_50-berlin.jpg.png HTTP/1.1" 200 886 0.004783
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_98_50-berlin.jpg.png HTTP/1.1" 200 625 0.009674
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_91_50-berlin.jpg.png HTTP/1.1" 200 627 0.004122
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_92_50-berlin.jpg.png HTTP/1.1" 200 501 0.008172
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_101_50-berlin.jpg.png HTTP/1.1" 200 630 0.003835
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_94_50-berlin.jpg.png HTTP/1.1" 200 522 0.008393
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_87_50-berlin.jpg.png HTTP/1.1" 200 1277 0.009631
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_99_50-berlin.jpg.png HTTP/1.1" 200 1270 0.005202
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_100_50-berlin.jpg.png HTTP/1.1" 200 647 0.007526
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_106_50-berlin.jpg.png HTTP/1.1" 200 726 0.007461
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_102_50-berlin.jpg.png HTTP/1.1" 200 653 0.005565
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_95_50-berlin.jpg.png HTTP/1.1" 200 606 0.014046
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_109_50-berlin.jpg.png HTTP/1.1" 200 634 0.007260
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_105_50-berlin.jpg.png HTTP/1.1" 200 605 0.005120
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_111_50-berlin.jpg.png HTTP/1.1" 200 638 0.007745
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_107_50-berlin.jpg.png HTTP/1.1" 200 396 0.004630
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_108_50-berlin.jpg.png HTTP/1.1" 200 462 0.008355
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_103_50-berlin.jpg.png HTTP/1.1" 200 663 0.004759
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_104_50-berlin.jpg.png HTTP/1.1" 200 637 0.009020
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_116_50-berlin.jpg.png HTTP/1.1" 200 731 0.007339
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_117_50-berlin.jpg.png HTTP/1.1" 200 516 0.005610
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_112_50-berlin.jpg.png HTTP/1.1" 200 727 0.005670
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_113_50-berlin.jpg.png HTTP/1.1" 200 617 0.006484
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_114_50-berlin.jpg.png HTTP/1.1" 200 550 0.007327
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_115_50-berlin.jpg.png HTTP/1.1" 200 529 0.006348
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_110_50-berlin.jpg.png HTTP/1.1" 200 591 0.007885
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_119_50-berlin.jpg.png HTTP/1.1" 200 713 0.006351
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_124_50-berlin.jpg.png HTTP/1.1" 200 655 0.007473
::1 - - [2017-09-26 16:30:05] "GET /temp-file/conv2d_16_120_50-berlin.jpg.png HTTP/1.1" 200 467 0.007683
::1 - - [2017-09-26 16:30:06] "GET /temp-file/conv2d_16_121_50-berlin.jpg.png HTTP/1.1" 200 1260 0.003179
::1 - - [2017-09-26 16:30:06] "GET /temp-file/conv2d_16_122_50-berlin.jpg.png HTTP/1.1" 200 596 0.007085
::1 - - [2017-09-26 16:30:06] "GET /temp-file/conv2d_16_118_50-berlin.jpg.png HTTP/1.1" 200 889 0.005014
::1 - - [2017-09-26 16:30:06] "GET /temp-file/conv2d_16_125_50-berlin.jpg.png HTTP/1.1" 200 641 0.010628
::1 - - [2017-09-26 16:30:06] "GET /temp-file/conv2d_16_126_50-berlin.jpg.png HTTP/1.1" 200 508 0.002851
::1 - - [2017-09-26 16:30:06] "GET /temp-file/conv2d_16_127_50-berlin.jpg.png HTTP/1.1" 200 413 0.012303
::1 - - [2017-09-26 16:30:06] "GET /temp-file/conv2d_16_123_50-berlin.jpg.png HTTP/1.1" 200 490 0.006590

In [ ]:
# Alternative mit noch mehr Visualisierungsmöglichkeiten
# https://github.com/raghakot/keras-vis

Nutzung mit Server Installationen


In [ ]:
# Erfordert einen lokalen Flask Server
!curl -H "Content-Type: application/json" -X GET -d '{"url": "https://github.com/DJCordhose/speed-limit-signs/raw/master/data/real-world/1000/70-house-detail.jpg"}' http://127.0.0.1:5000

In [ ]:
!curl -H "Content-Type: application/json" -X GET -d '{"url": "https://github.com/DJCordhose/speed-limit-signs/raw/master/data/real-world/4/100-sky-cutoff-detail.jpg"}' http://127.0.0.1:5000

2. Google Cloud ML Service


In [ ]:
# Example for iris, model exported as Tensorflow
# gsutil cp -R 1 gs://irisnn
# create model and version at https://console.cloud.google.com/mlengine
# in a DOS shell on local machine in this folder
# gcloud ml-engine predict --model=irisnn --json-instances=./sample_iris.json
# SCORES
# [0.9954029321670532, 0.004596732556819916, 3.3544753819114703e-07]