code/utils/data_utils.py
def load_sub_omniglot(path,n=0):

	"""
	path => Path of train directory or test directory
	"""
	X=[]
	y = []
	cat_dict = {}
	lang_dict = {}
	curr_y = n

	# we load every alphabet seperately so we can isolate them later
	for alphabet in os.listdir(path):
		if alphabet == '.DS_Store':
			continue
		print("loading alphabet: " + alphabet)
		lang_dict[alphabet] = [curr_y,None]
		alphabet_path = os.path.join(path,alphabet)

		# every letter/category has it's own column in the array, so  load seperately
		for letter in os.listdir(alphabet_path):
			if letter == '.DS_Store':
				continue
			cat_dict[curr_y] = (alphabet, letter)
			category_images=[]
			letter_path = os.path.join(alphabet_path, letter)

			# read all the images in the current category
			for filename in os.listdir(letter_path):
				image_path = os.path.join(letter_path, filename)
				image = imread(image_path)
				category_images.append(image)
				y.append(curr_y)
			try:
				#X.append(np.stack(category_images))
				X += list(np.stack(category_images))
			# edge case  - last one
			except ValueError as e:
				print(e)
				print("error - category_images:", category_images)
			curr_y += 1
			lang_dict[alphabet][1] = curr_y - 1
	y = np.vstack(y)
	X = np.stack(X)
	print(X.shape,y.shape,len(np.unique(y)))
	return X,y

	path => Path of train directory or test directory
	
path => Path of train directory or test directory
path = > Path of train directory or test directory
def load_sub_omniglot(path,n=0):
	X=[]
	y = []
	cat_dict = {}
	lang_dict = {}
	curr_y = n
	for alphabet in os.listdir(path):
		if alphabet == '.DS_Store':
			continue
		print("loading alphabet: " + alphabet)
		lang_dict[alphabet] = [curr_y,None]
		alphabet_path = os.path.join(path,alphabet)
		for letter in os.listdir(alphabet_path):
			if letter == '.DS_Store':
				continue
			cat_dict[curr_y] = (alphabet, letter)
			category_images=[]
			letter_path = os.path.join(alphabet_path, letter)
			for filename in os.listdir(letter_path):
				image_path = os.path.join(letter_path, filename)
				image = imread(image_path)
				category_images.append(image)
				y.append(curr_y)
			try:
				X += list(np.stack(category_images))
			except ValueError as e:
				print(e)
				print("error - category_images:", category_images)
			curr_y += 1
			lang_dict[alphabet][1] = curr_y - 1
	y = np.vstack(y)
	X = np.stack(X)
	print(X.shape,y.shape,len(np.unique(y)))
	return X,y
def load_sub_omniglot ( path , n = 0 ) : X = [ ] y = [ ] cat_dict = { } lang_dict = { } curr_y = n for alphabet in os . listdir ( path ) : if alphabet == '.DS_Store' : continue print ( "loading alphabet: " + alphabet ) lang_dict [ alphabet ] = [ curr_y , None ] alphabet_path = os . path . join ( path , alphabet ) for letter in os . listdir ( alphabet_path ) : if letter == '.DS_Store' : continue cat_dict [ curr_y ] = ( alphabet , letter ) category_images = [ ] letter_path = os . path . join ( alphabet_path , letter ) for filename in os . listdir ( letter_path ) : image_path = os . path . join ( letter_path , filename ) image = imread ( image_path ) category_images . append ( image ) y . append ( curr_y ) try : X += list ( np . stack ( category_images ) ) except ValueError as e : print ( e ) print ( "error - category_images:" , category_images ) curr_y += 1 lang_dict [ alphabet ] [ 1 ] = curr_y - 1 y = np . vstack ( y ) X = np . stack ( X ) print ( X . shape , y . shape , len ( np . unique ( y ) ) ) return X , y
path => Path of train directory or test directory
path = > Path of train directory or test directory
"""
	path => Path of train directory or test directory
	""" # we load every alphabet seperately so we can isolate them later # every letter/category has it's own column in the array, so  load seperately # read all the images in the current category #X.append(np.stack(category_images)) # edge case  - last one
path
n