-
Notifications
You must be signed in to change notification settings - Fork 0
/
usage.py
32 lines (29 loc) · 1.04 KB
/
usage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
How to use CMATERdb dataset
Author: Omkar Prabhu (prabhuomkar)
License: Apache 2.0
"""
import numpy as np
import os
def load(numeral_type, path=None):
""" Loads npz format type of data for given type of numeral
Args:
numeral_type (string): type of numeral to load
path (string): path of the directory where dataset exists (only when the dataset exists in a different location)
Returns:
None
"""
if path:
train = np.load(path+'/training-images.npz')
test = np.load(path+'/testing-images.npz')
else:
train = np.load(os.path.join(os.path.dirname(__file__), '../datasets/'+numeral_type+'-numerals/training-images.npz'))
test = np.load(os.path.join(os.path.dirname(__file__), '../datasets/'+numeral_type+'-numerals/testing-images.npz'))
print('Total Training: ', str(len(train['labels'])))
print('Total Testing: ', str(len(test['labels'])))
# Access Image
print(train['images'][0])
# Access Label
print(train['labels'][0])
if __name__ == '__main__':
load('devanagari')