#NEWLINE# def multiscale_patches_gen_fixed( images , scale_factors = [ 1.0 ] , patch_sizes = [ ( 50 , 50 ) ] , chunk_size = 4096 , augmentation_transforms = None , rng = np . random ) : #NEWLINE# #INDENT# if ( augmentation_transforms is None ) : #NEWLINE# #INDENT# augmentation_transforms = [ tform_identity ] #NEWLINE# #UNINDENT# assert ( len ( patch_sizes ) == len ( scale_factors ) ) #NEWLINE# num_images = len ( images ) #NEWLINE# num_tfs = len ( augmentation_transforms ) #NEWLINE# num_patches = ( num_images * num_tfs ) #NEWLINE# num_chunks = int ( np . ceil ( ( num_patches / float ( chunk_size ) ) ) ) #NEWLINE# idx = 0 #NEWLINE# for n in xrange ( num_chunks ) : #NEWLINE# #INDENT# chunks_x = [ np . zeros ( ( chunk_size , p_x , p_y ) , dtype = 'float32' ) for ( p_x , p_y ) in patch_sizes ] #NEWLINE# chunk_shape = np . zeros ( ( chunk_size , 2 ) , dtype = 'float32' ) #NEWLINE# chunk_length = chunk_size #NEWLINE# for k in xrange ( chunk_size ) : #NEWLINE# #INDENT# if ( idx >= num_patches ) : #NEWLINE# #INDENT# chunk_length = k #NEWLINE# break #NEWLINE# #UNINDENT# img = images [ ( idx // num_tfs ) ] #NEWLINE# img = uint_to_float ( img ) #NEWLINE# tf = augmentation_transforms [ ( idx % num_tfs ) ] #NEWLINE# sfs = [ ( sf ( img ) if callable ( sf ) else sf ) for sf in scale_factors ] #NEWLINE# patches = perturb_multiscale_fixed ( img , sfs , tf , target_shapes = p_x ) #NEWLINE# for ( chunk_x , patch ) in zip ( chunks_x , patches ) : #NEWLINE# #INDENT# chunk_x [ k ] = patch #NEWLINE# #UNINDENT# chunk_shape [ k ] = img . shape #NEWLINE# idx += 1 #NEWLINE# #UNINDENT# ( yield ( chunks_x , chunk_shape , chunk_length ) )