changeset 134:4981c729149c

Fixed various bugs in pipeline for Python 2.5 support
author boulanni <nicolas_boulanger@hotmail.com>
date Sat, 20 Feb 2010 02:09:09 -0500
parents a4e5128ef2cb
children 36010ff90255
files transformations/pipeline.py
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/transformations/pipeline.py	Sat Feb 20 02:07:29 2010 -0500
+++ b/transformations/pipeline.py	Sat Feb 20 02:09:09 2010 -0500
@@ -55,7 +55,7 @@
 from add_background_image import AddBackground
 from affine_transform import AffineTransformation
 from ttf2jpg import ttf2jpg
-from ..pycaptcha.Facade import generateCaptcha
+from pycaptcha.Facade import generateCaptcha
 
 if DEBUG:
     from visualizer import Visualizer
@@ -226,9 +226,9 @@
         r = numpy.random.rand()
         if r <= prob_font:
             yield ttf.generate_image()
-        elif r <= prob_font + prob_captcha:
+        elif r <=prob_font + prob_captcha:
             (arr, charac) = generateCaptcha(0,1)
-            yield arr.astype(numpy.float32)/255, L.index(charac)
+            yield arr.astype(numpy.float32)/255, L.index(charac[0])
         elif r <= prob_font + prob_captcha + prob_ocr:
             j = numpy.random.randint(len(ocr_labels))
             yield ocr_img[j].astype(numpy.float32)/255, ocr_labels[j]
@@ -268,7 +268,7 @@
     -d, --ocrlabel-file: path to filetensor (.ft) labels file (OCR labels)
     -a, --prob-font: probability of using a raw font image
     -b, --prob-captcha: probability of using a captcha image
-    -e, --prob-ocr: probability of using an ocr image
+    -g, --prob-ocr: probability of using an ocr image
     '''
 
 # See run_pipeline.py
@@ -300,7 +300,8 @@
     reload_mode = False
 
     try:
-        opts, args = getopt.getopt(get_argv(), "rm:z:o:p:x:s:f:l:c:d:a:b:e:", ["reload","max-complexity=", "probability-zero=", "output-file=", "params-output-file=", "labels-output-file=", "stop-after=", "data-file=", "label-file=", "ocr-file=", "ocrlabel-file=", "prob-font=", "prob-captcha=", "prob-ocr="])
+        opts, args = getopt.getopt(get_argv(), "rm:z:o:p:x:s:f:l:c:d:a:b:g:", ["reload","max-complexity=", "probability-zero=", "output-file=", "params-output-file=", "labels-output-file=", 
+"stop-after=", "data-file=", "label-file=", "ocr-file=", "ocrlabel-file=", "prob-font=", "prob-captcha=", "prob-ocr="])
     except getopt.GetoptError, err:
         # print help information and exit:
         print str(err) # will print something like "option -a not recognized"
@@ -337,7 +338,7 @@
             prob_font = float(a)
         elif o in ('-b', "--prob-captcha"):
             prob_captcha = float(a)
-        elif o in ('-e', "--prob-ocr"):
+        elif o in ('-g', "--prob-ocr"):
             prob_ocr = float(a)
         else:
             assert False, "unhandled option"