frgfm
commited on
Commit
·
b60b209
1
Parent(s):
17af543
docs: Updated README and config
Browse files- README.md +120 -0
- config.json +1 -0
README.md
CHANGED
|
@@ -1,3 +1,123 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- image-classification
|
| 5 |
+
- pytorch
|
| 6 |
+
- onnx
|
| 7 |
+
datasets:
|
| 8 |
+
- wildfire
|
| 9 |
---
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
# MobileNet V3 - Large model
|
| 13 |
+
|
| 14 |
+
Pretrained on a dataset for wildfire binary classification (soon to be shared). The MobileNet V3 architecture was introduced in [this paper](https://arxiv.org/pdf/1905.02244.pdf).
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
## Model description
|
| 18 |
+
|
| 19 |
+
The core idea of the author is to simplify the final stage, while using SiLU as activations and making Squeeze-and-Excite blocks larger.
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
## Installation
|
| 23 |
+
|
| 24 |
+
### Prerequisites
|
| 25 |
+
|
| 26 |
+
Python 3.6 (or higher) and [pip](https://pip.pypa.io/en/stable/)/[conda](https://docs.conda.io/en/latest/miniconda.html) are required to install PyroVision.
|
| 27 |
+
|
| 28 |
+
### Latest stable release
|
| 29 |
+
|
| 30 |
+
You can install the last stable release of the package using [pypi](https://pypi.org/project/pyrovision/) as follows:
|
| 31 |
+
|
| 32 |
+
```shell
|
| 33 |
+
pip install pyrovision
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
or using [conda](https://anaconda.org/pyronear/pyrovision):
|
| 37 |
+
|
| 38 |
+
```shell
|
| 39 |
+
conda install -c pyronear pyrovision
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
### Developer mode
|
| 43 |
+
|
| 44 |
+
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](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) first)*:
|
| 45 |
+
|
| 46 |
+
```shell
|
| 47 |
+
git clone https://github.com/pyronear/pyro-vision.git
|
| 48 |
+
pip install -e pyro-vision/.
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
## Usage instructions
|
| 53 |
+
|
| 54 |
+
```python
|
| 55 |
+
from PIL import Image
|
| 56 |
+
from torchvision.transforms import Compose, ConvertImageDtype, Normalize, PILToTensor, Resize
|
| 57 |
+
from torchvision.transforms.functional import InterpolationMode
|
| 58 |
+
from pyrovision.models import model_from_hf_hub
|
| 59 |
+
|
| 60 |
+
model = model_from_hf_hub("pyronear/mobilenet_v3_large").eval()
|
| 61 |
+
|
| 62 |
+
img = Image.open(path_to_an_image).convert("RGB")
|
| 63 |
+
|
| 64 |
+
# Preprocessing
|
| 65 |
+
config = model.default_cfg
|
| 66 |
+
transform = Compose([
|
| 67 |
+
Resize(config['input_shape'][1:], interpolation=InterpolationMode.BILINEAR),
|
| 68 |
+
PILToTensor(),
|
| 69 |
+
ConvertImageDtype(torch.float32),
|
| 70 |
+
Normalize(config['mean'], config['std'])
|
| 71 |
+
])
|
| 72 |
+
|
| 73 |
+
input_tensor = transform(img).unsqueeze(0)
|
| 74 |
+
|
| 75 |
+
# Inference
|
| 76 |
+
with torch.inference_mode():
|
| 77 |
+
output = model(input_tensor)
|
| 78 |
+
probs = output.squeeze(0).softmax(dim=0)
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
## Citation
|
| 83 |
+
|
| 84 |
+
Original paper
|
| 85 |
+
|
| 86 |
+
```bibtex
|
| 87 |
+
@article{DBLP:journals/corr/abs-1905-02244,
|
| 88 |
+
author = {Andrew Howard and
|
| 89 |
+
Mark Sandler and
|
| 90 |
+
Grace Chu and
|
| 91 |
+
Liang{-}Chieh Chen and
|
| 92 |
+
Bo Chen and
|
| 93 |
+
Mingxing Tan and
|
| 94 |
+
Weijun Wang and
|
| 95 |
+
Yukun Zhu and
|
| 96 |
+
Ruoming Pang and
|
| 97 |
+
Vijay Vasudevan and
|
| 98 |
+
Quoc V. Le and
|
| 99 |
+
Hartwig Adam},
|
| 100 |
+
title = {Searching for MobileNetV3},
|
| 101 |
+
journal = {CoRR},
|
| 102 |
+
volume = {abs/1905.02244},
|
| 103 |
+
year = {2019},
|
| 104 |
+
url = {http://arxiv.org/abs/1905.02244},
|
| 105 |
+
eprinttype = {arXiv},
|
| 106 |
+
eprint = {1905.02244},
|
| 107 |
+
timestamp = {Thu, 27 May 2021 16:20:51 +0200},
|
| 108 |
+
biburl = {https://dblp.org/rec/journals/corr/abs-1905-02244.bib},
|
| 109 |
+
bibsource = {dblp computer science bibliography, https://dblp.org}
|
| 110 |
+
}
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
Source of this implementation
|
| 114 |
+
|
| 115 |
+
```bibtex
|
| 116 |
+
@software{chintala_torchvision_2017,
|
| 117 |
+
author = {Chintala, Soumith},
|
| 118 |
+
month = {4},
|
| 119 |
+
title = {{Torchvision}},
|
| 120 |
+
url = {https://github.com/pytorch/vision},
|
| 121 |
+
year = {2017}
|
| 122 |
+
}
|
| 123 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"mean": [0.485, 0.456, 0.406], "std": [0.229, 0.224, 0.225], "arch": "mobilenet_v3_large", "interpolation": "bilinear", "input_shape": [3, 224, 224], "classes": ["Wildfire"]}
|