Created
November 19, 2018 15:51
-
-
Save tomellis/29e561b7e957c8bdb16eff30a8375762 to your computer and use it in GitHub Desktop.
Extract images from recordio format
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
from mxnet import recordio | |
import mxnet as mx | |
import cv2 | |
import matplotlib.pyplot as plt | |
from PIL import Image | |
record = mx.recordio.MXRecordIO('mlclassify_train.rec', 'r') | |
i = 0 | |
while True: | |
item = record.read() | |
if not item: | |
break | |
header, img = mx.recordio.unpack_img(item) | |
filename = "aeroplane%s.jpg" % i | |
cv2.imwrite(filename, img) | |
i += 1 | |
b,g,r = cv2.split(img) | |
img = cv2.merge([r,g,b]) | |
plt.imshow(img) | |
record.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment