pylocron

PyTorch implementations of recent Computer Vision tricks (ReXNet, RepVGG, Unet3p, YOLOv4, CIoU loss, AdaBelief, PolyLoss, MobileOne). Other additions: AdEMAMix

https://github.com/frgfm/holocron

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.7%) to scientific vocabulary

Keywords

ademamix computer-vision cspdarknet53 darknet deep-learning object-detection pytorch resnet rexnet tridentnet unet-image-segmentation yolo yolov4

Keywords from Contributors

mesh interpretability simulations distribution sequences projection interactive optim agents hacking
Last synced: 6 months ago · JSON representation ·

Repository

PyTorch implementations of recent Computer Vision tricks (ReXNet, RepVGG, Unet3p, YOLOv4, CIoU loss, AdaBelief, PolyLoss, MobileOne). Other additions: AdEMAMix

Basic Info
Statistics
  • Stars: 328
  • Watchers: 5
  • Forks: 48
  • Open Issues: 9
  • Releases: 6
Topics
ademamix computer-vision cspdarknet53 darknet deep-learning object-detection pytorch resnet rexnet tridentnet unet-image-segmentation yolo yolov4
Created over 6 years ago · Last pushed 11 months ago
Metadata Files
Readme Contributing Funding License Code of conduct Citation Codeowners Security

README.md

CI Status ruff ruff Test coverage percentage

PyPi Status Conda Version pyversions License

Huggingface Spaces Open in Colab

Documentation Status

Implementations of recent Deep Learning tricks in Computer Vision, easily paired up with your favorite framework and model zoo.

Holocrons were information-storage datacron devices used by both the Jedi Order and the Sith that contained ancient lessons or valuable information in holographic form.

Source: Wookieepedia

Quick Tour

Open In Colab

This project was created for quality implementations, increased developer flexibility and maximum compatibility with the PyTorch ecosystem. For instance, here is a short snippet to showcase how Holocron models are meant to be used:

```python from PIL import Image from torchvision.transforms import Compose, ConvertImageDtype, Normalize, PILToTensor, Resize from torchvision.transforms.functional import InterpolationMode from holocron.models.classification import repvgg_a0

Load your model

model = repvgg_a0(pretrained=True).eval()

Read your image

img = Image.open(pathtoan_image).convert("RGB")

Preprocessing

config = model.default_cfg transform = Compose([ Resize(config['input_shape'][1:], interpolation=InterpolationMode.BILINEAR), PILToTensor(), ConvertImageDtype(torch.float32), Normalize(config['mean'], config['std']) ])

input_tensor = transform(img).unsqueeze(0)

Inference

with torch.inferencemode(): output = model(inputtensor) print(config['classes'][output.squeeze(0).argmax().item()], output.squeeze(0).softmax(dim=0).max()) ```

Installation

Prerequisites

Python 3.9 (or higher) and pip/conda are required to install Holocron.

Latest stable release

You can install the last stable release of the package using pypi as follows:

shell pip install pylocron

or using conda:

shell conda install -c frgfm pylocron

Developer mode

Alternatively, if you wish to use the latest features of the project that haven't made their way to a release yet, you can install the package from source (install Git first):

shell git clone https://github.com/frgfm/Holocron.git pip install -e Holocron/.

Paper references

PyTorch layers for every need

Models for vision tasks

Vision-related operations

Trying something else than Adam

More goodies

Documentation

The full package documentation is available here for detailed specifications.

Demo app

The project includes a minimal demo app using Gradio

demo_app

You can check the live demo, hosted on :hugs: HuggingFace Spaces :hugs: over here :point_down: Hugging Face Spaces

Reference scripts

Reference scripts are provided to train your models using holocron on famous public datasets. Those scripts currently support the following vision tasks: - Image classification - Object detection - Semantic segmentation

Latency benchmark

You crave for SOTA performances, but you don't know whether it fits your needs in terms of latency?

In the table below, you will find a latency benchmark for all supported models:

| Arch | GPU mean (std) | CPU mean (std) | | ------------------------------------------------------------ | ----------------- | ------------------ | | repvgg_a0* | 3.14ms (0.87ms) | 23.28ms (1.21ms) | | repvgg_a1* | 4.13ms (1.00ms) | 29.61ms (0.46ms) | | repvgg_a2* | 7.35ms (1.11ms) | 46.87ms (1.27ms) | | repvgg_b0* | 4.23ms (1.04ms) | 33.16ms (0.58ms) | | repvgg_b1* | 12.48ms (0.96ms) | 100.66ms (1.46ms) | | repvgg_b2* | 20.12ms (0.31ms) | 155.90ms (1.59ms) | | repvgg_b3* | 24.94ms (1.70ms) | 224.68ms (14.27ms) | | rexnet1_0x | 6.01ms (0.26ms) | 13.66ms (0.21ms) | | rexnet1_3x | 6.43ms (0.10ms) | 19.13ms (2.05ms) | | rexnet1_5x | 6.46ms (0.28ms) | 21.06ms (0.24ms) | | rexnet2_0x | 6.75ms (0.21ms) | 31.77ms (3.28ms) | | rexnet2_2x | 6.92ms (0.51ms) | 33.61ms (0.60ms) | | sknet50 | 11.40ms (0.38ms) | 54.03ms (3.35ms) | | sknet101 | 23.55 ms (1.11ms) | 94.89ms (5.61ms) | | sknet152 | 69.81ms (0.60ms) | 253.07ms (3.33ms) | | tridentnet50 | 16.62ms (1.21ms) | 142.85ms (5.33ms) | | res2net5026w4s | 9.25ms (0.22ms) | 41.84ms (0.80ms) | | resnet50d | 36.97ms (3.58ms) | 36.97ms (3.58ms) | | pyconv_resnet50 | 20.03ms (0.28ms) | 178.85ms (2.35ms) | | pyconvhg_resnet50 | 38.41ms (0.33ms) | 301.03ms (12.39ms) | | darknet24 | 3.94ms (1.08ms) | 29.39ms (0.78ms) | | darknet19 | 3.17ms (0.59ms) | 26.36ms (2.80ms) | | darknet53 | 7.12ms (1.35ms) | 53.20ms (1.17ms) | | cspdarknet53 | 6.41ms (0.21ms) | 48.05ms (3.68ms) | | cspdarknet53_mish | 6.88ms (0.51ms) | 67.78ms (2.90ms) |

The reported latency for RepVGG models is the one of the reparametrized version

This benchmark was performed over 100 iterations on (224, 224) inputs, on a laptop to better reflect performances that can be expected by common users. The hardware setup includes an Intel(R) Core(TM) i7-10750H for the CPU, and a NVIDIA GeForce RTX 2070 with Max-Q Design for the GPU.

You can run this latency benchmark for any model on your hardware as follows:

bash python scripts/eval_latency.py rexnet1_0x

All script arguments can be checked using python scripts/eval_latency.py --help

Docker container

If you wish to deploy containerized environments, you can use the provided Dockerfile to build a docker image:

shell make build-api

Minimal API template

Looking for a boilerplate to deploy a model from Holocron with a REST API? Thanks to the wonderful FastAPI framework, you can do this easily.

Deploy your API locally

Run your API in a docker container as follows:

shell make start-api

In order to stop the container, use make stop-api

What you have deployed

Your API is now running on port 8080, with its documentation http://localhost:8080/redoc and requestable routes:

python import requests with open('/path/to/your/img.jpeg', 'rb') as f: data = f.read() response = requests.post("http://localhost:8080/classification", files={'file': data}).json()

Citation

If you wish to cite this project, feel free to use this BibTeX reference:

bibtex @software{Fernandez_Holocron_2020, author = {Fernandez, François-Guillaume}, month = {5}, title = {{Holocron}}, url = {https://github.com/frgfm/Holocron}, year = {2020} }

Contributing

Any sort of contribution is greatly appreciated!

You can find a short guide in CONTRIBUTING to help grow this project!

License

Distributed under the Apache 2.0 License. See LICENSE for more information.

Owner

  • Name: F-G Fernandez
  • Login: frgfm
  • Kind: user
  • Location: Paris, FR
  • Company: @relaycli @pyronear

Deep Learning Engineer by day, Open Source contributor by night :bat:

Citation (CITATION.cff)

cff-version: 1.2.0
type: software
message: "If you use this software in your work, please cite it as below."
authors:
- family-names: "Fernandez"
  given-names: "François-Guillaume"
title: "Holocron"
date-released: 2020-05-11
url: "https://github.com/frgfm/Holocron"

GitHub Events

Total
  • Watch event: 9
  • Delete event: 36
  • Issue comment event: 73
  • Push event: 20
  • Pull request review event: 3
  • Pull request event: 77
  • Fork event: 1
  • Create event: 37
Last Year
  • Watch event: 9
  • Delete event: 36
  • Issue comment event: 73
  • Push event: 20
  • Pull request review event: 3
  • Pull request event: 77
  • Fork event: 1
  • Create event: 37

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 357
  • Total Committers: 4
  • Avg Commits per committer: 89.25
  • Development Distribution Score (DDS): 0.101
Past Year
  • Commits: 19
  • Committers: 2
  • Avg Commits per committer: 9.5
  • Development Distribution Score (DDS): 0.474
Top Committers
Name Email Commits
F-G Fernandez f****3@h****r 321
dependabot[bot] 4****] 32
lostanlen m****n@g****m 3
imgbot[bot] 3****] 1

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 8
  • Total pull requests: 274
  • Average time to close issues: 5 months
  • Average time to close pull requests: 7 days
  • Total issue authors: 3
  • Total pull request authors: 3
  • Average comments per issue: 1.0
  • Average comments per pull request: 1.35
  • Merged pull requests: 169
  • Bot issues: 0
  • Bot pull requests: 136
Past Year
  • Issues: 0
  • Pull requests: 69
  • Average time to close issues: N/A
  • Average time to close pull requests: 7 days
  • Issue authors: 0
  • Pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 1.81
  • Merged pull requests: 12
  • Bot issues: 0
  • Bot pull requests: 60
Top Authors
Issue Authors
  • frgfm (7)
  • beargolden (1)
  • dependabot[bot] (1)
  • r1ckya (1)
Pull Request Authors
  • dependabot[bot] (226)
  • frgfm (154)
  • felixdittrich92 (1)
Top Labels
Issue Labels
module: models (4) type: new feature (3) type: enhancement (2) module: nn (2) topic: documentation (2) module: optim (2) ext: docs (1) ext: tests (1) github_actions (1) dependencies (1) type: misc (1) ext: ci (1) module: trainer (1) module: ops (1) topic: build (1) module: utils (1) ext: references (1) topic: onnx (1) critical (1)
Pull Request Labels
dependencies (226) python (194) ext: api (82) topic: build (77) type: enhancement (74) topic: documentation (69) ext: tests (58) module: models (54) type: misc (50) func: build (39) module: nn (36) topic: ci (28) github_actions (23) ext: references (22) module: trainer (19) module: optim (18) type: bug (18) module: ops (12) module: utils (12) module: transforms (10) ext: demo (10) ext: scripts (9) type: new feature (9) topic: style (8) ext: ci (6) type: code quality (4) ext: docs (4) topic: docs (4) type: fix (4) topic: classification (1)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 28 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 2
  • Total versions: 5
  • Total maintainers: 1
pypi.org: pylocron

Modules, operations and models for computer vision in PyTorch

  • Documentation: https://pylocron.readthedocs.io/
  • License: Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
  • Latest release: 0.2.1
    published over 3 years ago
  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 2
  • Downloads: 28 Last month
Rankings
Downloads: 4.1%
Average: 8.6%
Dependent packages count: 10.1%
Dependent repos count: 11.6%
Maintainers (1)
Last synced: 6 months ago

Dependencies

api/poetry.lock pypi
  • atomicwrites 1.4.1 develop
  • attrs 21.4.0 develop
  • httpcore 0.15.0 develop
  • httpx 0.23.0 develop
  • iniconfig 1.1.1 develop
  • pluggy 1.0.0 develop
  • py 1.11.0 develop
  • pytest 7.1.2 develop
  • pytest-asyncio 0.18.3 develop
  • rfc3986 1.5.0 develop
  • tomli 2.0.1 develop
  • anyio 3.6.1
  • certifi 2022.6.15
  • charset-normalizer 2.1.0
  • click 8.1.3
  • colorama 0.4.5
  • fastapi 0.79.0
  • filelock 3.7.1
  • flatbuffers 2.0
  • h11 0.12.0
  • huggingface-hub 0.8.1
  • idna 3.3
  • numpy 1.23.1
  • onnxruntime 1.11.1
  • packaging 21.3
  • pillow 9.2.0
  • protobuf 4.21.2
  • pydantic 1.9.1
  • pyparsing 3.0.9
  • python-multipart 0.0.5
  • pyyaml 6.0
  • requests 2.28.1
  • six 1.16.0
  • sniffio 1.2.0
  • starlette 0.19.1
  • tqdm 4.64.0
  • typing-extensions 4.3.0
  • urllib3 1.26.10
  • uvicorn 0.18.2
api/pyproject.toml pypi
  • httpx >=0.23.0 develop
  • pytest >=5.3.2,<8.0.0 develop
  • pytest-asyncio >=0.14.0,<1.0.0 develop
  • requests ^2.20.0 develop
  • Pillow >=8.4.0
  • fastapi >=0.65.2,<1.0.0
  • huggingface-hub >=0.4.0,<1.0.0
  • numpy ^1.19.5
  • onnxruntime ^1.10.0
  • python ^3.8
  • python-multipart ==0.0.5
  • uvicorn >=0.11.1
demo/requirements.txt pypi
  • Pillow >=8.4.0
  • gradio >=3.0.2,<4.0.0
  • huggingface-hub >=0.4.0,<1.0.0
  • numpy >=1.19.5,<2.0.0
  • onnxruntime >=1.10.0,<2.0.0
.github/workflows/builds.yml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
.github/workflows/demo.yml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
.github/workflows/doc-status.yml actions
  • actions/setup-python v1 composite
.github/workflows/docs.yaml actions
  • JamesIves/github-pages-deploy-action 3.7.1 composite
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
  • webfactory/ssh-agent v0.4.1 composite
.github/workflows/pr-labels.yml actions
  • actions/checkout v2 composite
  • actions/github-script 0.3.0 composite
  • actions/setup-python v2 composite
.github/workflows/pull_requests.yml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/labeler v4 composite
  • actions/setup-python v2 composite
.github/workflows/scripts.yml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
.github/workflows/style.yml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
  • actions/setup-python v2 composite
.github/workflows/tests.yml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/download-artifact v2 composite
  • actions/setup-python v1 composite
  • actions/upload-artifact v2 composite
  • codecov/codecov-action v1 composite
  • frgfm/validate-python-headers main composite
api/Dockerfile docker
  • tiangolo/uvicorn-gunicorn-fastapi python3.8-slim build
.github/workflows/publish.yml actions
  • actions/cache v4 composite
  • actions/checkout v2 composite
  • actions/setup-python v4 composite
  • actions/setup-python v1 composite
  • conda-incubator/setup-miniconda v3 composite
.github/workflows/push.yml actions
  • abatilo/actions-poetry v2 composite
  • actions/checkout v2 composite
  • actions/setup-python v4 composite
  • docker/login-action v3 composite
api/docker-compose.yml docker
  • traefik v2.9.6
pyproject.toml pypi
  • Pillow >=8.4.0,!=9.2.0
  • fastprogress >=1.0.0,<2.0.0
  • huggingface-hub >=0.4.0
  • matplotlib >=3.0.0,<4.0.0
  • numpy >=1.17.2,<2.0.0
  • torch >=2.0.0,<3.0.0
  • torchvision >=0.15.0,<1.0.0
  • tqdm >=4.1.0
setup.py pypi