Przeglądaj źródła

Pretiffied a print statement and tested run_classifier script.

Taddeus Kroes 14 lat temu
rodzic
commit
06246989c0
2 zmienionych plików z 13 dodań i 3 usunięć
  1. 5 1
      src/create_characters.py
  2. 8 2
      src/run_classifier.py

+ 5 - 1
src/create_characters.py

@@ -21,6 +21,8 @@ def load_characters(neighbours, blur_scale, verbose=0):
         chars = []
 
         for char in sorted(listdir(IMAGES_FOLDER)):
+            count = 0
+
             for image in sorted(listdir(IMAGES_FOLDER + char)):
                 image = GrayscaleImage(IMAGES_FOLDER + char + '/' + image)
                 norm = NormalizedCharacterImage(image, blur=blur_scale, \
@@ -29,8 +31,10 @@ def load_characters(neighbours, blur_scale, verbose=0):
                 character.get_single_cell_feature_vector(neighbours)
                 chars.append(character)
 
+                count += 1
+
                 if verbose:
-                    print 'Loaded character %s' % char
+                    print 'Loaded character %s %d times' % (char, count)
 
         if verbose:
             print 'Saving characters...'

+ 8 - 2
src/run_classifier.py

@@ -7,14 +7,20 @@ from create_characters import load_test_set
 from create_classifier import load_classifier
 
 if len(argv) < 3:
-    print 'Usage: python %s NEIGHBOURS BLUR_SCALE' % argv[0]
+    print 'Usage: python %s NEIGHBOURS BLUR_SCALE [ C GAMMA ]' % argv[0]
     exit(1)
 
 neighbours = int(argv[1])
 blur_scale = float(argv[2])
 
 # Load classifier
-classifier = load_classifier(neighbours, blur_scale, verbose=1)
+if len(argv) > 4:
+    c = float(argv[3])
+    gamma = float(argv[4])
+    classifier = load_classifier(neighbours, blur_scale, c=c, gamma=gamma, \
+            verbose=1)
+else:
+    classifier = load_classifier(neighbours, blur_scale, verbose=1)
 
 # Load test set
 test_set = load_test_set(neighbours, blur_scale, verbose=1)