Skip to content

Commit

Permalink
Enable passing of original and predicted label for a image
Browse files Browse the repository at this point in the history
  • Loading branch information
adotg committed Feb 6, 2018
1 parent 7480048 commit 2a18346
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions show_img.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import numpy as np
from IPython.display import display

def show_img(img_arr, label_arr, meta, index):
def default_label_fn(i, original):
return original

def show_img(img_arr, label_arr, meta, index, label_fn=default_label_fn):
"""
Given a numpy array of image from CIFAR-10 labels this method transform the data so that PIL can read and show
the image.
Expand All @@ -17,4 +20,4 @@ def show_img(img_arr, label_arr, meta, index):
rgb = np.dstack([r, g, b])
img = Image.fromarray(np.array(rgb), 'RGB')
display(img)
print(meta[label_arr[index][0]].decode('utf-8'))
print(label_fn(index, meta[label_arr[index][0]].decode('utf-8')))

0 comments on commit 2a18346

Please sign in to comment.