def process_image(img, scale, isotropic, crop, mean):
 if isotropic:
  img_shape = tf.to_float(tf.shape(img)[:2])
  min_length = tf.minimum(img_shape[0], img_shape[1])
  new_shape = tf.to_int32(((scale / min_length) * img_shape))
 else:
  new_shape = tf.pack([scale, scale])
 img = tf.image.resize_images(img, new_shape[0], new_shape[1])
 offset = ((new_shape - crop) / 2)
 img = tf.slice(img, begin=tf.pack([offset[0], offset[1], 0]), size=tf.pack([crop, crop, (-1)]))
 return (tf.to_float(img) - mean)

def process_image ( img , scale , isotropic , crop , mean ) : if isotropic : img_shape = tf . to_float ( tf . shape ( img ) [ : 2 ] ) min_length = tf . minimum ( img_shape [ 0 ] , img_shape [ 1 ] ) new_shape = tf . to_int32 ( ( ( scale / min_length ) * img_shape ) ) else : new_shape = tf . pack ( [ scale , scale ] ) img = tf . image . resize_images ( img , new_shape [ 0 ] , new_shape [ 1 ] ) offset = ( ( new_shape - crop ) / 2 ) img = tf . slice ( img , begin = tf . pack ( [ offset [ 0 ] , offset [ 1 ] , 0 ] ) , size = tf . pack ( [ crop , crop , ( - 1 ) ] ) ) return ( tf . to_float ( img ) - mean )
process a source pil image through a series of image processors .