Last active
November 22, 2018 09:38
-
-
Save tomellis/f239d586bd8009cebb30f341debb2ea8 to your computer and use it in GitHub Desktop.
Add a step to inspect the data of AerocraftML notebook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!wget https://s3-us-west-2.amazonaws.com/awsgeek-devweek-austin/mlclassify_train.rec --quiet | |
!mkdir -p training_data | |
%matplotlib inline | |
from mxnet import recordio | |
import mxnet as mx | |
import cv2 | |
import matplotlib.pyplot as plt | |
import matplotlib.image as mpimg | |
from PIL import Image | |
record = mx.recordio.MXRecordIO('mlclassify_train.rec', 'r') | |
## Extract all images from recordio file | |
i = 0 | |
while True: | |
item = record.read() | |
if not item: | |
break | |
header, img = mx.recordio.unpack_img(item) | |
filename = "training_data/aeroplane%s.jpg" % i | |
cv2.imwrite(filename, img) | |
i += 1 | |
record.close() | |
## Display the image without extracting from file | |
#b,g,r = cv2.split(img) | |
#img = cv2.merge([r,g,b]) | |
#plt.imshow(img) | |
## Plot images for displaying in the notebook | |
object_categories = ['dornier-328','boeing-747','airbus-a320'] | |
f, axarr = plt.subplots(1,3, figsize=(30,30)) | |
col = 0 | |
for i in range(3): | |
im = Image.open('training_data/aeroplane%d.jpg' % (i+1)) | |
axarr[col].text(0, 0, '%s' %(object_categories[i] ), fontsize=30, color='blue') | |
frame = axarr[col].imshow(im) | |
col += 1 | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment