iteration_scheme=SequentialScheme( train.num_examples, batch_size)) # upscaled_stream = MinimumImageDimensions(stream, (100, 100), which_sources=('image_features',)) downscaled_stream = DownscaleMinDimension(stream, 100, which_sources=('image_features', )) # Our images are of different sizes, so we'll use a Fuel transformer # to take random crops of size (32 x 32) from each image cropped_stream = RandomFixedSizeCrop(downscaled_stream, (100, 100), which_sources=('image_features', )) rotated_stream = Random2DRotation(cropped_stream, math.pi / 6, which_sources=('image_features', )) flipped_stream = RandomHorizontalFlip(rotated_stream, which_sources=('image_features', )) # We'll use a simple MLP, so we need to flatten the images # from (channel, width, height) to simply (features,) float_stream = ScaleAndShift(flipped_stream, 1. / 255, 0, which_sources=('image_features', )) float32_stream = Cast(float_stream, numpy.float32, which_sources=('image_features', )) start_server(float32_stream, port=port)
def sample_transformations(thestream): cast_stream = Cast(data_stream=thestream, dtype='float32', which_sources=('features', )) return cast_stream