Mercurial > ift6266
comparison data_generation/transformations/gimp_script.py @ 266:1e4e60ddadb1
Merge. Ah, et dans le dernier commit, j'avais oublié de mentionner que j'ai ajouté du code pour gérer l'isolation de différents clones pour rouler des expériences et modifier le code en même temps.
author | fsavard |
---|---|
date | Fri, 19 Mar 2010 10:56:16 -0400 |
parents | dd2df78fcf47 |
children | d5b2b6397a5a |
comparison
equal
deleted
inserted
replaced
265:c8fe09a65039 | 266:1e4e60ddadb1 |
---|---|
28 | 28 |
29 def getpix(): | 29 def getpix(): |
30 return numpy.fromstring(dest_rgn[:,:], 'UInt8').astype(numpy.float32).reshape((32,32)).T / 255.0 | 30 return numpy.fromstring(dest_rgn[:,:], 'UInt8').astype(numpy.float32).reshape((32,32)).T / 255.0 |
31 | 31 |
32 class GIMP1(): | 32 class GIMP1(): |
33 def get_settings_names(self): | 33 def __init__(self, blur_bool = True): |
34 #This is used to avoid blurring for PNIST | |
35 self.blur_bool = blur_bool | |
36 | |
37 def get_settings_names(self, blur_bool = True): | |
34 return ['mblur_length', 'mblur_angle', 'pinch'] | 38 return ['mblur_length', 'mblur_angle', 'pinch'] |
35 | 39 |
36 def regenerate_parameters(self, complexity): | 40 def regenerate_parameters(self, complexity): |
37 if complexity: | 41 if complexity: |
38 self.mblur_length = abs(int(round(numpy.random.normal(0, 3*complexity)))) | 42 self.mblur_length = abs(int(round(numpy.random.normal(0, 3*complexity)))) |
39 else: | 43 else: |
40 self.mblur_length = 0 | 44 self.mblur_length = 0 |
41 self.mblur_angle = int(round(numpy.random.uniform(0,360))) | 45 self.mblur_angle = int(round(numpy.random.uniform(0,360))) |
42 self.pinch = numpy.random.uniform(-complexity, 0.7*complexity) | 46 self.pinch = numpy.random.uniform(-complexity, 0.7*complexity) |
43 | 47 |
44 return [self.mblur_length, self.mblur_angle, self.pinch] | 48 return [self.mblur_length, self.mblur_angle, self.pinch] |
45 | 49 |
46 def transform_image(self, image): | 50 def transform_image(self, image): |
47 if self.mblur_length or self.pinch: | 51 if self.mblur_length or self.pinch: |
48 setpix(image) | 52 setpix(image) |
49 if self.mblur_length: | 53 if self.mblur_length and self.blur_bool: |
50 pdb.plug_in_mblur(img, layer1, 0, self.mblur_length, self.mblur_angle, 0, 0) | 54 pdb.plug_in_mblur(img, layer1, 0, self.mblur_length, self.mblur_angle, 0, 0) |
51 if self.pinch: | 55 if self.pinch: |
52 pdb.plug_in_whirl_pinch(img, layer1, 0.0, self.pinch, 1.0) | 56 pdb.plug_in_whirl_pinch(img, layer1, 0.0, self.pinch, 1.0) |
53 image = getpix() | 57 image = getpix() |
54 | 58 |