def get_static_detectors(self): if DetectorTask._detectors is None: DetectorTask._detectors = { 'coco_mobilenet': detector.TFDetector( model_path=model_path, class_index_to_string=coco_class_index_to_string), 'face_mtcnn': detector.FaceDetector() } return DetectorTask._detectors
def load_detector(self,cd): if cd.pk not in DetectorTask._detectors: if cd.detector_type == DeepModel.TFD: DetectorTask._detectors[cd.pk] = detector.TFDetector(model_path=cd.get_model_path(), class_index_to_string=cd.class_index_to_string) elif cd.detector_type == DeepModel.YOLO: DetectorTask._detectors[cd.pk] = detector.YOLODetector(cd.get_yolo_args()) elif cd.name == 'face': DetectorTask._detectors[cd.pk] = detector.FaceDetector() elif cd.name == 'textbox': DetectorTask._detectors[cd.pk] = detector.TextBoxDetector(model_path=cd.get_model_path()) else: raise ValueError,"{}".format(cd.pk)
def get_static_detectors(self): if DetectorTask._detectors is None: detectors_root = "{}/detectors/".format(settings.MEDIA_ROOT) DetectorTask._detectors = { 'coco': detector.TFDetector( model_path=detectors_root + 'coco/coco_mobilenet.pb', class_index_to_string=coco_class_index_to_string), 'face': detector.FaceDetector(), 'textbox': detector.TextBoxDetector() } return DetectorTask._detectors
def load_detector(cls, cd): cd.ensure() if cd.pk not in Detectors._detectors: if cd.detector_type == TrainedModel.TFD: Detectors._detectors[cd.pk] = detector.TFDetector( model_path=cd.get_model_path(), class_index_to_string=cd.arguments['class_index_to_string'] ) elif cd.detector_type == TrainedModel.YOLO: raise NotImplementedError("YOLO model has been removed") elif cd.name == 'face': Detectors._detectors[cd.pk] = detector.FaceDetector() elif cd.name == 'textbox': Detectors._detectors[cd.pk] = detector.TextBoxDetector( model_path=cd.get_model_path()) else: raise ValueError, "{}".format(cd.pk)
def load_detector(cls, cd): cd.ensure() if cd.pk not in Detectors._detectors: if cd.detector_type == TrainedModel.TFD: Detectors._detectors[cd.pk] = detector.TFDetector( model_path=cd.get_model_path(), class_index_to_string=cd.arguments['class_index_to_string'] ) elif cd.detector_type == TrainedModel.YOLO: # class_names = {k: v for k, v in json.loads(self.class_names)} # args = {'root_dir': model_dir, # 'detector_pk': self.pk, # 'class_names':{i: k for k, i in class_names.items()} # } Detectors._detectors[cd.pk] = detector.YOLODetector( cd.get_yolo_args()) elif cd.name == 'face': Detectors._detectors[cd.pk] = detector.FaceDetector() elif cd.name == 'textbox': Detectors._detectors[cd.pk] = detector.TextBoxDetector( model_path=cd.get_model_path()) else: raise ValueError, "{}".format(cd.pk)
def get_static_detectors(self): if DetectorTask._detectors is None: DetectorTask._detectors = {'coco': detector.TFDetector(model_path=model_path,class_index_to_string=coco_class_index_to_string), 'face': detector.FaceDetector(), 'textbox':detector.TextBoxDetector()} return DetectorTask._detectors