#NEWLINE# def _example_transform( self , example , _ ) : #NEWLINE# #INDENT# if ( ( example . ndim > 3 ) or ( example . ndim < 2 ) ) : #NEWLINE# #INDENT# raise NotImplementedError #NEWLINE# #UNINDENT# ( min_height , min_width ) = self . minimum_shape #NEWLINE# ( original_height , original_width ) = example . shape [ ( - 2 ) : ] #NEWLINE# if ( ( original_height < min_height ) or ( original_width < min_width ) ) : #NEWLINE# #INDENT# dt = example . dtype #NEWLINE# if ( example . ndim == 3 ) : #NEWLINE# #INDENT# im = example . transpose ( 1 , 2 , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# im = example #NEWLINE# #UNINDENT# im = Image . fromarray ( im ) #NEWLINE# ( width , height ) = multiplier . size #NEWLINE# multiplier = max ( 1 , ( min_width / width ) , ( min_height / height ) ) #NEWLINE# width = int ( math . ceil ( ( width * multiplier ) ) ) #NEWLINE# height = int ( math . ceil ( ( height * multiplier ) ) ) #NEWLINE# im = numpy . array ( im . resize ( ( width , height ) ) ) . astype ( dt ) #NEWLINE# if ( im . ndim == 3 ) : #NEWLINE# #INDENT# example = im . transpose ( 2 , 0 , 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# example = im #NEWLINE# #UNINDENT# #UNINDENT# return example