fdet-offline-1.0.5
توضیحات
An easy to use face detection module based on MTCNN and RetinaFace algorithms.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | fdet-offline-1.0.5 |
| نام | fdet-offline |
| نسخه کتابخانه | 1.0.5 |
| نگهدارنده | ['Viktoria R.'] |
| ایمیل نگهدارنده | ['viktoria.rosjo@gmail.com'] |
| نویسنده | Viktoria R. |
| ایمیل نویسنده | viktoria.rosjo@gmail.com |
| آدرس صفحه اصلی | https://github.com/vikrosj/fdet-offline |
| آدرس اینترنتی | https://pypi.org/project/fdet-offline/ |
| مجوز | - |
# FDet-Offline: just like FDet, but offline
### Download like this:
```console
pip install fdet-offline --find-links https://download.pytorch.org/whl/torch_stable.html
```
Package depends on torch-packages not in PyPi.
---
A version of [fdet](https://github.com/acnazarejr/fdet)
where you don't have to access the internet to download the weights.
These are the changes:
## MTCNN (only works for this model at the moment)
### 1.
In fdet/mtcnn.py, line 73-76, the url for the MTCNN-weights are listed:
```python
base_url = 'https://github.com/acnazarejr/fdet/releases/download/weights/'
self._pnet = self.__load_model(_PNet, base_url + 'mtcnn_pnet.pt')
self._rnet = self.__load_model(_RNet, base_url + 'mtcnn_rnet.pt')
self._onet = self.__load_model(_ONet, base_url + 'mtcnn_onet.pt')
```
I downloaded those weights and created packages to import them (because PyPi has a 100MB max on package size, this was the solution).
I put the weights in the directory **weights** in the package **fdet_offline_mtcnn_weights**.
The function **fdet_offline_mtcnn_weights.import_weights** takes *mtcnn_type* as input
and returns a partial function of [torch.load](https://pytorch.org/docs/stable/generated/torch.load.html#torch.load).
This partial function gets *map_location* from *__load_model*.
The previously mentioned fdet/mtcnn.py, line 73-76, now looks like this:
```python
self._pnet = self.__load_model(_PNet, 'pnet')
self._rnet = self.__load_model(_RNet, 'rnet')
self._onet = self.__load_model(_ONet, 'onet')
```
In fdet/mtcnn.py, what previously was (url was input):
```python
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)
```
is now (mtcnn_type is input):
```python
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.
At fdet/mtcnn.py, line 427:
```python
state_dict = load_state_dict_from_url(url, map_location=self._device_control)
```
[load_state_dict_from_url](https://pytorch.org/docs/stable/_modules/torch/hub.html#load_state_dict_from_url), returns a [torch.load](https://pytorch.org/docs/stable/generated/torch.load.html#torch.load) which takes the weight-file as input.
I replaced the load_state_dict_from_url with torch.load, and that's it.
That line now states this instead;
```python
state_dict = torch.load(url, map_location=self._device_control)
```
نیازمندی
| مقدار | نام |
|---|---|
| ==0.12.6 | CacheControl |
| ==8.0.0 | Pillow |
| ==1.4.3 | appdirs |
| ==20.2.0 | attrs |
| ==2019.11.28 | certifi |
| ==3.0.4 | chardet |
| ==7.1.2 | click |
| ==0.4.4 | colorama |
| ==0.1.5 | colour |
| ==0.6.0 | contextlib2 |
| ==0.3.0 | distlib |
| ==1.4.0 | distro |
| ==1.0.0 | fdet-offline-mtcnn-weights |
| ==0.18.2 | future |
| ==1.0.1 | html5lib |
| ==2.8 | idna |
| ==1.1.1 | iniconfig |
| ==2.2.0 | ipaddr |
| ==0.12.2 | lockfile |
| ==0.6.2 | msgpack |
| ==1.19.2 | numpy |
| ==4.4.0.44 | opencv-python |
| ==20.3 | packaging |
| ==0.8.2 | pep517 |
| ==0.13.1 | pluggy |
| ==1.5 | progress |
| ==1.9.0 | py |
| ==2.4.6 | pyparsing |
| ==6.1.1 | pytest |
| ==0.1.21 | pytoml |
| ==2.22.0 | requests |
| ==1.3.3 | retrying |
| ==1.14.0 | six |
| ==0.10.1 | toml |
| ==1.6.0+cpu | torch |
| ==0.7.0+cpu | torchvision |
| ==0.5.6 | ttictoc |
| ==1.25.8 | urllib3 |
| ==0.5.1 | webencodings |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.8 | Python |
نحوه نصب
نصب پکیج whl fdet-offline-1.0.5:
pip install fdet-offline-1.0.5.whl
نصب پکیج tar.gz fdet-offline-1.0.5:
pip install fdet-offline-1.0.5.tar.gz