def load(self, model_path=None): for model_link, file_path in zip( Constant.FACE_DETECTION_PRETRAINED['PRETRAINED_MODEL_LINKS'], Constant.FACE_DETECTION_PRETRAINED['FILE_PATHS']): download_file(model_link, file_path) self.pnet, self.rnet, self.onet = Constant.FACE_DETECTION_PRETRAINED[ 'FILE_PATHS']
def load(self, model_path=None): # https://s3.amazonaws.com/amdegroot-models/ssd300_mAP_77.43_v2.pth if model_path is None: file_link = Constant.PRE_TRAIN_DETECTION_FILE_LINK # model_path = os.path.join(temp_path_generator(), "object_detection_pretrained.pth") model_path = temp_path_generator( ) + '_object_detection_pretrained.pth' download_file(file_link, model_path) # load net num_classes = len(VOC_CLASSES) + 1 # +1 for background self.model = self._build_ssd('test', 300, num_classes) # initialize SSD if self.device.startswith("cuda"): self.model.load_state_dict(torch.load(model_path)) else: self.model.load_state_dict( torch.load(model_path, map_location=lambda storage, loc: storage)) self.model.eval() print('Finished loading model!') self.model = self.model.to(self.device)
def load(self, model_path=None): temp_path = temp_path_generator() ensure_dir(temp_path) for model_link, file_path in zip(Constant.FACE_DETECTION_PRETRAINED['PRETRAINED_MODEL_LINKS'], Constant.FACE_DETECTION_PRETRAINED['FILE_NAMES']): download_file(model_link, f'{temp_path}/{file_path}')
def test_fetch(_): # Assert requests.get calls clean_dir(TEST_TEMP_DIR) mgc = download_file("dummy_url", TEST_TEMP_DIR + '/dummy_file') clean_dir(TEST_TEMP_DIR)