Toggle Navigation
Hatchery
Eggs
MNIST handwritten clock
extractData.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
extractData.py
raw
Content
import os from .metadata import * try: directory = '/'.join(__file__.split('/')[:-1]) except: directory = '/lib/mnist_handwritten_clock' print('directory: ', directory) def unpackImages(): try: os.mkdir('{}/digits'.format(directory)) except: pass byteLocation = 0 data = open('{}/data.txt'.format(directory), 'rb') try: for i in range(10): for j in range(imageNumbers[i]): f = open('{}/digits/{}_{}.PNG'.format(directory,i, j), 'wb') data.seek(byteLocation) f.write(data.read(imageSizes[i][j])) f.close() byteLocation += imageSizes[i][j] except: data.close() return False data.close() os.remove('{}/data.txt'.format(directory)) return True