Mercurial > ift6266
diff transformations/pipeline.py @ 108:a7cd8dd3221c
pipeline.py: placé les modules dans le bon ordre + store NIST en bytes plutôt qu'en float32 dans la RAM
author | boulanni <nicolas_boulanger@hotmail.com> |
---|---|
date | Mon, 15 Feb 2010 16:17:48 -0500 |
parents | 95c491bb5662 |
children | 9c45e0071b52 |
line wrap: on
line diff
--- a/transformations/pipeline.py Mon Feb 15 15:35:17 2010 -0500 +++ b/transformations/pipeline.py Mon Feb 15 16:17:48 2010 -0500 @@ -41,17 +41,19 @@ import pylab pylab.ion() -#from add_background_image import AddBackground -from affine_transform import AffineTransformation from PoivreSel import PoivreSel from thick import Thick from BruitGauss import BruitGauss +from DistorsionGauss import DistorsionGauss +from PermutPixel import PermutPixel from gimp_script import GIMP1 from Rature import Rature from contrast import Contrast -from Occlusion import Occlusion from local_elastic_distortions import LocalElasticDistorter from slant import Slant +from Occlusion import Occlusion +from add_background_image import AddBackground +from affine_transform import AffineTransformation if DEBUG: from visualizer import Visualizer @@ -60,7 +62,8 @@ # AFTER_EACH_MODULE_HOOK list (but not both, it's redundant) VISUALIZER = Visualizer(to_dir=DEBUG_OUTPUT_DIR, on_screen=False) -MODULE_INSTANCES = [Thick(),Slant(),GIMP1(),AffineTransformation(),LocalElasticDistorter(),Occlusion(),Rature(),Contrast()] +###---------------------order of transformation module +MODULE_INSTANCES = [Slant(),Thick(),AffineTransformation(),LocalElasticDistorter(),GIMP1(),Rature(),Occlusion(), PermutPixel(),DistorsionGauss(),AddBackground(), PoivreSel(), BruitGauss(), Contrast()] # These should have a "after_transform_callback(self, image)" method # (called after each call to transform_image in a module) @@ -201,11 +204,12 @@ self.ocr_data = open(ocr_path, 'rb') self.ocr_labels = open(ocrlabel_path, 'rb') +# cet iterator load tout en ram def nist_supp_iterator(nist, prob_font, prob_captcha, prob_ocr, num_img): - img = ft.read(nist.train_data).astype(numpy.float32)/255 + img = ft.read(nist.train_data) labels = ft.read(nist.train_labels) if prob_ocr: - ocr_img = ft.read(nist.ocr_data).astype(numpy.float32)/255 + ocr_img = ft.read(nist.ocr_data) ocr_labels = ft.read(nist.ocr_labels) for i in xrange(num_img): @@ -216,10 +220,10 @@ pass #get captcha elif r <= prob_font + prob_captcha + prob_ocr: j = numpy.random.randint(len(ocr_labels)) - yield ocr_img[j], ocr_labels[j] + yield ocr_img[j].astype(numpy.float32)/255, ocr_labels[j] else: j = numpy.random.randint(len(labels)) - yield img[j], labels[j] + yield img[j].astype(numpy.float32)/255, labels[j] # Mostly for debugging, for the moment, just to see if we can