frgfm commited on
Commit
823b978
1 Parent(s): 1837184

docs: Updated README and config

Browse files
Files changed (2) hide show
  1. README.md +111 -0
  2. config.json +1 -0
README.md CHANGED
@@ -1,3 +1,114 @@
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
+ - openfire
9
  ---
10
+
11
+
12
+ # ResNet-18 model
13
+
14
+ Pretrained on a dataset for wildfire binary classification (soon to be shared).
15
+
16
+ ## Model description
17
+
18
+ The core idea of the author is to help the gradient propagation through numerous layers by adding a skip connection.
19
+
20
+
21
+ ## Installation
22
+
23
+ ### Prerequisites
24
+
25
+ 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.
26
+
27
+ ### Latest stable release
28
+
29
+ You can install the last stable release of the package using [pypi](https://pypi.org/project/pyrovision/) as follows:
30
+
31
+ ```shell
32
+ pip install pyrovision
33
+ ```
34
+
35
+ or using [conda](https://anaconda.org/pyronear/pyrovision):
36
+
37
+ ```shell
38
+ conda install -c pyronear pyrovision
39
+ ```
40
+
41
+ ### Developer mode
42
+
43
+ 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)*:
44
+
45
+ ```shell
46
+ git clone https://github.com/pyronear/pyro-vision.git
47
+ pip install -e pyro-vision/.
48
+ ```
49
+
50
+
51
+ ## Usage instructions
52
+
53
+ ```python
54
+ from PIL import Image
55
+ from torchvision.transforms import Compose, ConvertImageDtype, Normalize, PILToTensor, Resize
56
+ from torchvision.transforms.functional import InterpolationMode
57
+ from pyrovision.models import model_from_hf_hub
58
+
59
+ model = model_from_hf_hub("pyronear/resnet18").eval()
60
+
61
+ img = Image.open(path_to_an_image).convert("RGB")
62
+
63
+ # Preprocessing
64
+ config = model.default_cfg
65
+ transform = Compose([
66
+ Resize(config['input_shape'][1:], interpolation=InterpolationMode.BILINEAR),
67
+ PILToTensor(),
68
+ ConvertImageDtype(torch.float32),
69
+ Normalize(config['mean'], config['std'])
70
+ ])
71
+
72
+ input_tensor = transform(img).unsqueeze(0)
73
+
74
+ # Inference
75
+ with torch.inference_mode():
76
+ output = model(input_tensor)
77
+ probs = output.squeeze(0).softmax(dim=0)
78
+ ```
79
+
80
+
81
+ ## Citation
82
+
83
+ Original paper
84
+
85
+ ```bibtex
86
+ @article{DBLP:journals/corr/HeZRS15,
87
+ author = {Kaiming He and
88
+ Xiangyu Zhang and
89
+ Shaoqing Ren and
90
+ Jian Sun},
91
+ title = {Deep Residual Learning for Image Recognition},
92
+ journal = {CoRR},
93
+ volume = {abs/1512.03385},
94
+ year = {2015},
95
+ url = {http://arxiv.org/abs/1512.03385},
96
+ eprinttype = {arXiv},
97
+ eprint = {1512.03385},
98
+ timestamp = {Wed, 17 Apr 2019 17:23:45 +0200},
99
+ biburl = {https://dblp.org/rec/journals/corr/HeZRS15.bib},
100
+ bibsource = {dblp computer science bibliography, https://dblp.org}
101
+ }
102
+ ```
103
+
104
+ Source of this implementation
105
+
106
+ ```bibtex
107
+ @software{chintala_torchvision_2017,
108
+ author = {Chintala, Soumith},
109
+ month = {4},
110
+ title = {{Torchvision}},
111
+ url = {https://github.com/pytorch/vision},
112
+ year = {2017}
113
+ }
114
+ ```
config.json ADDED
@@ -0,0 +1 @@
 
1
+ {"mean": [0.485, 0.456, 0.406], "std": [0.229, 0.224, 0.225], "arch": "resnet18", "interpolation": "bilinear", "input_shape": [3, 224, 224], "classes": ["Wildfire"]}