一个易于使用的基于MTCNN和RetinaFace算法的人脸检测模块。
fdet-offline的Python项目详细描述
FDet Offline:和FDet一样,但是离线
下载如下:
pip install fdet-offline --find-links https://download.pytorch.org/whl/torch_stable.html
包装取决于不在PyPi中的火炬包。在
fdet的版本 你不必上网下载重量。在
这些变化是:
MTCNN(目前仅适用于此型号)
1.
在fdet中/mtcnn.py,第73-76行,列出了MTCNN权重的url:
^{pr2}$我下载了这些权重并创建了包来导入它们(因为PyPi的包大小最大为100MB,这就是解决方案)。在
将重量放入目录中。 函数fdet_offline_mtcnn_weights.import_weights以mtcnn_type作为输入 并返回torch.load的部分函数。在
此部分函数从load_model获取map_location。在
前面提到的fdet/mtcnn.py,第73-76行,现在如下所示:
self._pnet=self.__load_model(_PNet,'pnet')self._rnet=self.__load_model(_RNet,'rnet')self._onet=self.__load_model(_ONet,'onet')
在fdet中/mtcnn.py,以前是什么(输入了url):
def__load_model(self,net_class:type,url:str)->torch.nn.Module:"""Download and construct the models"""try:state_dict=load_state_dict_from_url(url,map_location=self._device_control)
现在(mtcnn_type is input):
def__load_model(self,net_class:type,mtcnn_type:str)->torch.nn.Module:"""Download and construct the models"""try:load_state_dict=import_weights.load_partial(mtcnn_type)state_dict=load_state_dict(map_location=self._device_control)
2.
在fdet/mtcnn.py第427行:
state_dict=load_state_dict_from_url(url,map_location=self._device_control)
load_state_dict_from_url,返回以权重文件为输入的torch.load。 我将加载状态_dict_from_url替换为火炬负荷,就这样。在
这句话现在是这样说的
state_dict=torch.load(url,map_location=self._device_control)
- 项目
标签: