# -*- coding: utf-8 -*-
"""
Created on Mon Jan 09 14:01:35 2017

@author: sakurai
"""


from fuel.schemes import SequentialScheme
from fuel.streams import DataStream
from random_fixed_size_crop_mod import RandomFixedSizeCrop

from cars196_dataset import Cars196Dataset


def get_cars196_streams(crop_size=227, load_in_memory=False):
    # This scheme is dummy, since DataStream requires an iteration_scheme for
    # DataStream.produces_examples to be False in the constructor.
    dummy_scheme = SequentialScheme(1, 1)

    train_stream = RandomFixedSizeCrop(
        DataStream(Cars196Dataset(['train'], load_in_memory=load_in_memory),
                   iteration_scheme=dummy_scheme),
        (crop_size, crop_size), which_sources=("images"))
    test_stream = RandomFixedSizeCrop(
        DataStream(Cars196Dataset(['test'], load_in_memory=load_in_memory),
                   iteration_scheme=dummy_scheme),
        (crop_size, crop_size), which_sources=("images"))
    return train_stream, test_stream


if __name__ == '__main__':
    train, test = get_cars196_streams(load_in_memory=True)
    train.get_data([0, 1, 2])

@@ -272,62 +272,52 @@
 def 
-get_cars196_streams(crop_size=227, load_in_memory=Fals
+make_random_cropped_stream(dataset, crop_siz
 e):%0A
@@ -508,22 +508,16 @@
 1)%0A%0A    
-train_
 stream =
@@ -561,84 +561,16 @@
 eam(
-Cars196Dataset(%5B'train'%5D, load_in_memory=load_in_memory),%0A                  
+dataset,
  ite
@@ -664,62 +664,106 @@
     
-test_stream = RandomFixedSizeCrop(%0A        DataStream(
+return stream%0A%0A%0Adef get_cars196_streams(crop_size=227, load_in_memory=False):%0A    train_dataset = 
 Cars
@@ -776,19 +776,20 @@
 aset(%5B't
-est
+rain
 '%5D, load
@@ -818,118 +818,227 @@
 ory)
-,
 %0A    
-           
+train_stream = make_random_cropped_stream(train_dataset, crop_size)%0A%0A
     
-i
 te
-ration_scheme=dummy_scheme),%0A        (crop_size, crop_size), which_sources=(%22images%22))
+st_dataset = Cars196Dataset(%5B'test'%5D, load_in_memory=load_in_memory)%0A    test_stream = make_random_cropped_stream(test_dataset, crop_size)%0A
 %0A   

Extract common part