FDet-Offline: just like FDet, but offline
Download like this:
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 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:
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.
This partial function gets map_location from __load_model.
The previously mentioned fdet/mtcnn.py, line 73-76, now looks like this:
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):
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):
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:
state_dict = load_state_dict_from_url(url, map_location=self._device_control)
load_state_dict_from_url, returns a 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;
state_dict = torch.load(url, map_location=self._device_control)
Metadata
Release files for fdet-offline 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fdet-offline-1.0.5.tar.gz | 21.7 kB | Without provenance | Details for fdet-offline-1.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fdet_offline-1.0.5-py3-none-any.whl | Python 3 | none | any | Details for fdet_offline-1.0.5-py3-none-any.whl |
Total release size: 45.0 kB
Release files / fdet-offline-1.0.5.tar.gz
| Download URL | fdet-offline-1.0.5.tar.gz |
|---|---|
| Size | 21.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
62947fd7479c723bb8669c26d8b42b77d103cc057b0bec757dbdd12accf056ad
|
|
BLAKE2b-256 checksum How to use checksums |
3b76d00964e62e96407452fcdf50d3a957a275bc8a2f92fe2f66905b4a6f5197
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.0 requests/2.22.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
|
Release files / fdet_offline-1.0.5-py3-none-any.whl
| Download URL | fdet_offline-1.0.5-py3-none-any.whl |
|---|---|
| Size | 23.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
323f62d00c0ff9e28a43cd4423794286779df189474f2dd169923f689bcf3562
|
|
BLAKE2b-256 checksum How to use checksums |
27e27447aa1c885a8daf277a221df0b708ab7cd68e5331f34714c59f7f2620d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.0 requests/2.22.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
|
Security for fdet-offline 1.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.