swenkel commited on
Commit
0367d6a
·
1 Parent(s): 57699b7

text_recognition example argparse bug fix (#89)

Browse files
models/text_recognition_crnn/demo.py CHANGED
@@ -44,6 +44,10 @@ parser.add_argument('--target', '-t', type=int, default=targets[0], help=help_ms
44
  parser.add_argument('--charset', '-c', type=str, default='charset_36_EN.txt', help='Path to the charset file corresponding to the selected model.')
45
  parser.add_argument('--save', '-s', type=str, default=False, help='Set true to save results. This flag is invalid when using camera.')
46
  parser.add_argument('--vis', '-v', type=str2bool, default=True, help='Set true to open a window for result visualization. This flag is invalid when using camera.')
 
 
 
 
47
  args = parser.parse_args()
48
 
49
  def visualize(image, boxes, texts, color=(0, 255, 0), isClosed=True, thickness=2):
@@ -60,7 +64,7 @@ if __name__ == '__main__':
60
  recognizer = CRNN(modelPath=args.model, charsetPath=args.charset)
61
  # Instantiate DB for text detection
62
  detector = DB(modelPath='../text_detection_db/text_detection_DB_IC15_resnet18_2021sep.onnx',
63
- inputSize=[736, 736],
64
  binaryThreshold=0.3,
65
  polygonThreshold=0.5,
66
  maxCandidates=200,
@@ -106,7 +110,7 @@ if __name__ == '__main__':
106
  print('No frames grabbed!')
107
  break
108
 
109
- frame = cv.resize(frame, [736, 736])
110
  # Inference of text detector
111
  tm.start()
112
  results = detector.infer(frame)
 
44
  parser.add_argument('--charset', '-c', type=str, default='charset_36_EN.txt', help='Path to the charset file corresponding to the selected model.')
45
  parser.add_argument('--save', '-s', type=str, default=False, help='Set true to save results. This flag is invalid when using camera.')
46
  parser.add_argument('--vis', '-v', type=str2bool, default=True, help='Set true to open a window for result visualization. This flag is invalid when using camera.')
47
+ parser.add_argument('--width', type=int, default=736,
48
+ help='Preprocess input image by resizing to a specific width. It should be multiple by 32.')
49
+ parser.add_argument('--height', type=int, default=736,
50
+ help='Preprocess input image by resizing to a specific height. It should be multiple by 32.')
51
  args = parser.parse_args()
52
 
53
  def visualize(image, boxes, texts, color=(0, 255, 0), isClosed=True, thickness=2):
 
64
  recognizer = CRNN(modelPath=args.model, charsetPath=args.charset)
65
  # Instantiate DB for text detection
66
  detector = DB(modelPath='../text_detection_db/text_detection_DB_IC15_resnet18_2021sep.onnx',
67
+ inputSize=[args.width, args.height],
68
  binaryThreshold=0.3,
69
  polygonThreshold=0.5,
70
  maxCandidates=200,
 
110
  print('No frames grabbed!')
111
  break
112
 
113
+ frame = cv.resize(frame, [args.width, args.height])
114
  # Inference of text detector
115
  tm.start()
116
  results = detector.infer(frame)