def loadModel(): global nnet, textDetector, rectDetector, optionsDetector try: # Initialize npdetector with default configuration file. nnet = Detector(MASK_RCNN_DIR, MASK_RCNN_LOG_DIR) nnet.loadModel("latest") rectDetector = RectDetector() optionsDetector = OptionsDetector() optionsDetector.load("latest") # Initialize text detector. textDetector = TextDetector.get_static_module("eu")() textDetector.load("latest") return True except: return False
def __init__(self, NOMEROFF_NET_DIR, MASK_RCNN_DIR, MASK_RCNN_LOG_DIR, load_model="latest", options_detector="latest", text_detector_module="eu", load_text_detector="latest"): sys.path.append(NOMEROFF_NET_DIR) # Initialize npdetector with default configuration file. self.nnet = Detector(MASK_RCNN_DIR, MASK_RCNN_LOG_DIR) self.nnet.loadModel(load_model) self.rectDetector = RectDetector() self.optionsDetector = OptionsDetector() self.optionsDetector.load(options_detector) # Initialize text detector. self.textDetector = TextDetector.get_static_module( text_detector_module)() self.textDetector.load(load_text_detector)
numbers[time] = [imgs, textArr] print('Detected LP : "%s" in region [%s]' % (textArr, regionNames)) if cv2.waitKey(1) & 0xFF == ord('q'): break else: break return json.dumps(numbers) if __name__ == '__main__': app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER app.secret_key = 'mthfckin_key' print("loading model") nnet = Detector(MASK_RCNN_DIR, MASK_RCNN_LOG_DIR) nnet.loadModel("latest") rectDetector = RectDetector() optionsDetector = OptionsDetector() optionsDetector.load("latest") textDetector = TextDetector.get_static_module("eu")() textDetector.load("latest") print("model loaded") app.run()