Przeglądaj źródła

If tesseract can't read the image it will now display and ask what the word is

david 5 lat temu
rodzic
commit
a2b8565f8f
1 zmienionych plików z 13 dodań i 3 usunięć
  1. 13 3
      dataLoad.py

+ 13 - 3
dataLoad.py

@@ -342,8 +342,19 @@ def autotrain(difficult):
 
         with open(fileout + ".txt", "r") as fp:
             word = fp.read().strip().lower()
-            key_word[f'{difficult}_{x}'] = word
-            print(word)
+            if (word != ''):
+                key_word[f'{difficult}_{x}'] = word
+                print(word)
+            else:
+                print("UNKNOWN")
+                # Output the image
+                im = Image.open(fname)
+                pix = im.load()
+                size = im.size
+                img_s = output_image(pix, size)
+                for l in img_s:
+                    print(l)
+                key_word[f'{difficult}_{x}'] = input("Word: ")
 
 
 # Now to call all the previous functions
@@ -369,7 +380,6 @@ if args.download:
 
 if args.train:
     # Img Processing: Run thru every single category and every single word
-    wordDict = {}
     for level in ["e", "m", "h"]:
         autotrain(level)
     with open(args.JSON, 'w') as fp: