PytorchWildlife 1.2.2__tar.gz → 1.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pytorchwildlife-1.2.4/PKG-INFO +268 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/data/datasets.py +7 -7
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/data/transforms.py +13 -16
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/classification/resnet_base/amazon.py +2 -2
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/classification/resnet_base/base_classifier.py +4 -4
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/classification/resnet_base/custom_weights.py +6 -6
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/classification/resnet_base/opossum.py +2 -2
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/classification/resnet_base/serengeti.py +2 -2
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/classification/timm_base/base_classifier.py +4 -5
- pytorchwildlife-1.2.4/PytorchWildlife/models/detection/__init__.py +4 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/base_detector.py +12 -19
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/herdnet/animaloc/eval/lmds.py +8 -8
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/herdnet/herdnet.py +24 -40
- pytorchwildlife-1.2.4/PytorchWildlife/models/detection/rtdetr_apache/__init__.py +2 -0
- pytorchwildlife-1.2.4/PytorchWildlife/models/detection/rtdetr_apache/megadetectorv6_apache.py +44 -0
- pytorchwildlife-1.2.4/PytorchWildlife/models/detection/rtdetr_apache/rtdetr_apache_base.py +225 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/ultralytics_based/Deepfaune.py +1 -3
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/ultralytics_based/__init__.py +2 -1
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/ultralytics_based/megadetectorv6.py +12 -12
- pytorchwildlife-1.2.4/PytorchWildlife/models/detection/ultralytics_based/megadetectorv6_distributed.py +53 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/ultralytics_based/yolov5_base.py +9 -16
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/ultralytics_based/yolov8_base.py +32 -16
- pytorchwildlife-1.2.4/PytorchWildlife/models/detection/ultralytics_based/yolov8_distributed.py +232 -0
- pytorchwildlife-1.2.4/PytorchWildlife/models/detection/yolo_mit/__init__.py +2 -0
- pytorchwildlife-1.2.4/PytorchWildlife/models/detection/yolo_mit/megadetectorv6_mit.py +44 -0
- pytorchwildlife-1.2.4/PytorchWildlife/models/detection/yolo_mit/yolo/__init__.py +15 -0
- pytorchwildlife-1.2.4/PytorchWildlife/models/detection/yolo_mit/yolo/config.py +168 -0
- pytorchwildlife-1.2.4/PytorchWildlife/models/detection/yolo_mit/yolo_mit_base.py +220 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/utils/post_process.py +8 -8
- pytorchwildlife-1.2.4/PytorchWildlife.egg-info/PKG-INFO +268 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife.egg-info/SOURCES.txt +11 -1
- pytorchwildlife-1.2.4/README.md +225 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/setup.py +2 -2
- pytorchwildlife-1.2.2/PKG-INFO +0 -462
- pytorchwildlife-1.2.2/PytorchWildlife/models/detection/__init__.py +0 -2
- pytorchwildlife-1.2.2/PytorchWildlife.egg-info/PKG-INFO +0 -462
- pytorchwildlife-1.2.2/README.md +0 -431
- /pytorchwildlife-1.2.2/LICENSE → /pytorchwildlife-1.2.4/LICENSE.md +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PW_FT_classification/__init__.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PW_FT_classification/main.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/__init__.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/data/__init__.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/__init__.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/classification/__init__.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/classification/base_classifier.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/classification/resnet_base/__init__.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/classification/timm_base/DFNE.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/classification/timm_base/Deepfaune.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/classification/timm_base/__init__.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/herdnet/__init__.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/herdnet/animaloc/__init__.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/herdnet/animaloc/data/__init__.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/herdnet/animaloc/data/patches.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/herdnet/animaloc/data/types.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/herdnet/animaloc/eval/__init__.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/herdnet/animaloc/eval/stitchers.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/herdnet/dla.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/herdnet/model.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/ultralytics_based/megadetectorv5.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/utils/__init__.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/utils/misc.py +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife.egg-info/dependency_links.txt +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife.egg-info/requires.txt +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife.egg-info/top_level.txt +0 -0
- {pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/setup.cfg +0 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: PytorchWildlife
|
|
3
|
+
Version: 1.2.4
|
|
4
|
+
Summary: a PyTorch Collaborative Deep Learning Framework for Conservation.
|
|
5
|
+
Home-page: https://github.com/microsoft/CameraTraps/
|
|
6
|
+
Author: Andres Hernandez, Zhongqi Miao, Daniela Ruiz Lopez, Isai Daniel Chacon Silva
|
|
7
|
+
Author-email: v-hernandres@microsoft.com, zhongqimiao@microsoft.com, v-druizlopez@microsoft.com, v-ichaconsil@microsoft.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: pytorch_wildlife,pytorch,wildlife,megadetector,conservation,animal,detection,classification
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE.md
|
|
17
|
+
Requires-Dist: torch
|
|
18
|
+
Requires-Dist: torchvision
|
|
19
|
+
Requires-Dist: torchaudio
|
|
20
|
+
Requires-Dist: tqdm
|
|
21
|
+
Requires-Dist: Pillow
|
|
22
|
+
Requires-Dist: supervision==0.23.0
|
|
23
|
+
Requires-Dist: gradio
|
|
24
|
+
Requires-Dist: ultralytics
|
|
25
|
+
Requires-Dist: chardet
|
|
26
|
+
Requires-Dist: wget
|
|
27
|
+
Requires-Dist: yolov5
|
|
28
|
+
Requires-Dist: setuptools
|
|
29
|
+
Requires-Dist: scikit-learn
|
|
30
|
+
Requires-Dist: timm
|
|
31
|
+
Dynamic: author
|
|
32
|
+
Dynamic: author-email
|
|
33
|
+
Dynamic: classifier
|
|
34
|
+
Dynamic: description
|
|
35
|
+
Dynamic: description-content-type
|
|
36
|
+
Dynamic: home-page
|
|
37
|
+
Dynamic: keywords
|
|
38
|
+
Dynamic: license
|
|
39
|
+
Dynamic: license-file
|
|
40
|
+
Dynamic: requires-dist
|
|
41
|
+
Dynamic: requires-python
|
|
42
|
+
Dynamic: summary
|
|
43
|
+
|
|
44
|
+

|
|
45
|
+
|
|
46
|
+
<div align="center">
|
|
47
|
+
<font size="6"> A Collaborative Deep Learning Framework for Conservation </font>
|
|
48
|
+
<br>
|
|
49
|
+
<hr>
|
|
50
|
+
<a href="https://pypi.org/project/PytorchWildlife"><img src="https://img.shields.io/pypi/v/PytorchWildlife?color=limegreen" /></a>
|
|
51
|
+
<a href="https://pypi.org/project/PytorchWildlife"><img src="https://static.pepy.tech/badge/pytorchwildlife" /></a>
|
|
52
|
+
<a href="https://pypi.org/project/PytorchWildlife"><img src="https://img.shields.io/pypi/pyversions/PytorchWildlife" /></a>
|
|
53
|
+
<a href="https://huggingface.co/spaces/ai-for-good-lab/pytorch-wildlife"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Demo-blue" /></a>
|
|
54
|
+
<a href="https://colab.research.google.com/drive/1rjqHrTMzEHkMualr4vB55dQWCsCKMNXi?usp=sharing"><img src="https://img.shields.io/badge/Colab-Demo-blue?logo=GoogleColab" /></a>
|
|
55
|
+
<!-- <a href="https://colab.research.google.com/drive/16-OjFVQ6nopuP-gfqofYBBY00oIgbcr1?usp=sharing"><img src="https://img.shields.io/badge/Colab-Video detection-blue?logo=GoogleColab" /></a> -->
|
|
56
|
+
<a href="https://github.com/microsoft/CameraTraps/blob/main/LICENSE"><img src="https://img.shields.io/pypi/l/PytorchWildlife" /></a>
|
|
57
|
+
<a href="https://discord.gg/TeEVxzaYtm"><img src="https://img.shields.io/badge/any_text-Join_us!-blue?logo=discord&label=Discord" /></a>
|
|
58
|
+
<a href="https://microsoft.github.io/CameraTraps/"><img src="https://img.shields.io/badge/Docs-526CFE?logo=MaterialForMkDocs&logoColor=white" /></a>
|
|
59
|
+
<br><br>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## 📣 Announcements
|
|
65
|
+
|
|
66
|
+
### 🚀 We’re Open for Contributions!
|
|
67
|
+
|
|
68
|
+
We’re excited to announce that **Pytorch-Wildlife** is now open to community contributions!
|
|
69
|
+
If you’d like to get involved and help improve the project, we’d love to have you on board.
|
|
70
|
+
|
|
71
|
+
👉 **Check out our Contribution Guidelines:**
|
|
72
|
+
|
|
73
|
+
[📚 How to Participate](https://microsoft.github.io/CameraTraps/contribute/#how-to-participate)
|
|
74
|
+
|
|
75
|
+
You’ll find everything you need there — from how to pick an issue, to submitting your first pull request.
|
|
76
|
+
Let’s build this together! 🐾🌱
|
|
77
|
+
|
|
78
|
+
### V 1.2.4
|
|
79
|
+
|
|
80
|
+
The inference code for the MIT YOLO and Apache RT‑DETR models is now available! To use either one, just load it like any other PyTorch‑Wildlife model:
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from pw_detection import MegaDetectorV6MIT, MegaDetectorV6Apache
|
|
84
|
+
|
|
85
|
+
# MIT YOLO
|
|
86
|
+
detector = MegaDetectorV6MIT(
|
|
87
|
+
device=DEVICE,
|
|
88
|
+
pretrained=True,
|
|
89
|
+
version="MDV6-mit-yolov9-e"
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
# Apache RT‑DETR
|
|
93
|
+
detector = MegaDetectorV6Apache(
|
|
94
|
+
device=DEVICE,
|
|
95
|
+
pretrained=True,
|
|
96
|
+
version="MDV6-apa-rtdetr-e"
|
|
97
|
+
)
|
|
98
|
+
```
|
|
99
|
+
Valid versions:
|
|
100
|
+
- MDV6-mit-yolov9-c
|
|
101
|
+
- MDV6-mit-yolov9-e
|
|
102
|
+
- MDV6-apa-rtdetr-c
|
|
103
|
+
- MDV6-apa-rtdetr-e
|
|
104
|
+
|
|
105
|
+
You can also try out the full pipeline using the `detection_classification_pipeline_demo.py` script in the demo folder.
|
|
106
|
+
|
|
107
|
+
#### Previous versions:
|
|
108
|
+
- [What's New](https://microsoft.github.io/CameraTraps/releases/release_notes/)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
## 👋 Welcome to Pytorch-Wildlife
|
|
112
|
+
|
|
113
|
+
**PyTorch-Wildlife** is an AI platform designed for the AI for Conservation community to create, modify, and share powerful AI conservation models. It allows users to directly load a variety of models including [MegaDetector](https://microsoft.github.io/CameraTraps/megadetector/), [DeepFaune](https://microsoft.github.io/CameraTraps/megadetector/), and [HerdNet](https://github.com/Alexandre-Delplanque/HerdNet) from our ever expanding [model zoo](https://microsoft.github.io/CameraTraps/model_zoo/megadetector/) for both animal detection and classification. In the future, we will also include models that can be used for applications, including underwater images and bioacoustics. We want to provide a unified and straightforward experience for both practicioners and developers in the AI for conservation field. Your engagement with our work is greatly appreciated, and we eagerly await any feedback you may have.
|
|
114
|
+
|
|
115
|
+
Explore the codebase, functionalities and user interfaces of **Pytorch-Wildlife** through our [documentation](https://microsoft.github.io/CameraTraps/), interactive [HuggingFace web app](https://huggingface.co/spaces/AndresHdzC/pytorch-wildlife) or local [demos and notebooks](./demo).
|
|
116
|
+
|
|
117
|
+
## 🚀 Quick Start
|
|
118
|
+
|
|
119
|
+
👇 Here is a quick example on how to perform detection and classification on a single image using `PyTorch-wildlife`
|
|
120
|
+
```python
|
|
121
|
+
import numpy as np
|
|
122
|
+
from PytorchWildlife.models import detection as pw_detection
|
|
123
|
+
from PytorchWildlife.models import classification as pw_classification
|
|
124
|
+
|
|
125
|
+
img = np.random.randn(3, 1280, 1280)
|
|
126
|
+
|
|
127
|
+
# Detection
|
|
128
|
+
detection_model = pw_detection.MegaDetectorV6() # Model weights are automatically downloaded.
|
|
129
|
+
detection_result = detection_model.single_image_detection(img)
|
|
130
|
+
|
|
131
|
+
#Classification
|
|
132
|
+
classification_model = pw_classification.AI4GAmazonRainforest() # Model weights are automatically downloaded.
|
|
133
|
+
classification_results = classification_model.single_image_classification(img)
|
|
134
|
+
```
|
|
135
|
+
More models can be found in our [model zoo](https://microsoft.github.io/CameraTraps/model_zoo/megadetector/)
|
|
136
|
+
|
|
137
|
+
## ⚙️ Install Pytorch-Wildlife
|
|
138
|
+
```
|
|
139
|
+
pip install PytorchWildlife
|
|
140
|
+
```
|
|
141
|
+
Please refer to our [installation guide](https://microsoft.github.io/CameraTraps/installation/) for more installation information.
|
|
142
|
+
|
|
143
|
+
## 📃 Documentation
|
|
144
|
+
Please also go to our newly made dofumentation page for more information: [](https://microsoft.github.io/CameraTraps/)
|
|
145
|
+
|
|
146
|
+
## 🖼️ Examples
|
|
147
|
+
|
|
148
|
+
### Image detection using `MegaDetector`
|
|
149
|
+
<img src="https://zenodo.org/records/15376499/files/animal_det_1.JPG" alt="animal_det_1" width="300"/><br>
|
|
150
|
+
*Credits to Universidad de los Andes, Colombia.*
|
|
151
|
+
|
|
152
|
+
### Image classification with `MegaDetector` and `AI4GAmazonRainforest`
|
|
153
|
+
<img src="https://zenodo.org/records/15376499/files/animal_clas_1.png" alt="animal_clas_1" width="300"/><br>
|
|
154
|
+
*Credits to Universidad de los Andes, Colombia.*
|
|
155
|
+
|
|
156
|
+
### Opossum ID with `MegaDetector` and `AI4GOpossum`
|
|
157
|
+
<img src="https://zenodo.org/records/15376499/files/opossum_det.png" alt="opossum_det" width="300"/><br>
|
|
158
|
+
*Credits to the Agency for Regulation and Control of Biosecurity and Quarantine for Galápagos (ABG), Ecuador.*
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
## :fountain_pen: Cite us!
|
|
162
|
+
We have recently published a [summary paper on Pytorch-Wildlife](https://arxiv.org/abs/2405.12930). The paper has been accepted as an oral presentation at the [CV4Animals workshop](https://www.cv4animals.com/) at this CVPR 2024. Please feel free to cite us!
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
@misc{hernandez2024pytorchwildlife,
|
|
166
|
+
title={Pytorch-Wildlife: A Collaborative Deep Learning Framework for Conservation},
|
|
167
|
+
author={Andres Hernandez and Zhongqi Miao and Luisa Vargas and Sara Beery and Rahul Dodhia and Juan Lavista},
|
|
168
|
+
year={2024},
|
|
169
|
+
eprint={2405.12930},
|
|
170
|
+
archivePrefix={arXiv},
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Also, don't forget to cite our original paper for MegaDetector:
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
@misc{beery2019efficient,
|
|
178
|
+
title={Efficient Pipeline for Camera Trap Image Review},
|
|
179
|
+
author={Sara Beery and Dan Morris and Siyu Yang},
|
|
180
|
+
year={2019}
|
|
181
|
+
eprint={1907.06772},
|
|
182
|
+
archivePrefix={arXiv},
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## 🤝 Existing Collaborators and Contributors
|
|
187
|
+
|
|
188
|
+
The extensive collaborative efforts of Megadetector have genuinely inspired us, and we deeply value its significant contributions to the community. As we continue to advance with Pytorch-Wildlife, our commitment to delivering technical support to our existing partners on MegaDetector remains the same.
|
|
189
|
+
|
|
190
|
+
Here we list a few of the organizations that have used MegaDetector. We're only listing organizations who have given us permission to refer to them here or have posted publicly about their use of MegaDetector.
|
|
191
|
+
|
|
192
|
+
We are also building a list of contributors and will release in future updates! Thank you for your efforts!
|
|
193
|
+
|
|
194
|
+
<details>
|
|
195
|
+
<summary><font size="3">👉 Full list of organizations</font></summary>
|
|
196
|
+
|
|
197
|
+
<ul>
|
|
198
|
+
<li>(Newly Added) <a href="https://www.terroiko.fr/">TerrOïko</a> (<a href="https://www.terroiko.fr/ocapi">OCAPI platform</a>)</li>
|
|
199
|
+
<li><a href="http://azdeq.gov/">Arizona Department of Environmental Quality</a></li>
|
|
200
|
+
<li><a href="https://blackbirdenv.com/">Blackbird Environmental</a></li>
|
|
201
|
+
<li><a href="https://camelotproject.org/">Camelot</a></li>
|
|
202
|
+
<li><a href="https://cpawsnab.org/">Canadian Parks and Wilderness Society (CPAWS) Northern Alberta Chapter</a></li>
|
|
203
|
+
<li><a href="https://conservationxlabs.com/">Conservation X Labs</a></li>
|
|
204
|
+
<li><a href="https://www.czu.cz/en">Czech University of Life Sciences Prague</a></li>
|
|
205
|
+
<li><a href="https://www.consult-ecologic.com/">EcoLogic Consultants Ltd.</a></li>
|
|
206
|
+
<li><a href="http://www.ebd.csic.es/inicio">Estación Biológica de Doñana</a></li>
|
|
207
|
+
<li><a href="https://idfg.idaho.gov/">Idaho Department of Fish and Game</a></li>
|
|
208
|
+
<li><a href="https://www.islandconservation.org/">Island Conservation</a></li>
|
|
209
|
+
<li><a href="https://carnivorecoexistence.info/myall-lakes-dingo-project/">Myall Lakes Dingo Project</a></li>
|
|
210
|
+
<li><a href="https://pnptc.org/">Point No Point Treaty Council</a></li>
|
|
211
|
+
<li><a href="https://www.ramat-hanadiv.org.il/en/">Ramat Hanadiv Nature Park</a></li>
|
|
212
|
+
<li><a href="https://spea.pt/en/">SPEA (Portuguese Society for the Study of Birds)</a></li>
|
|
213
|
+
<li><a href="https://www.synthetaic.com/">Synthetaic</a></li>
|
|
214
|
+
<li><a href="https://taronga.org.au/">Taronga Conservation Society</a></li>
|
|
215
|
+
<li><a href="https://www.nature.org/en-us/about-us/where-we-work/united-states/wyoming/">The Nature Conservancy in Wyoming</a></li>
|
|
216
|
+
<li><a href="https://wildeyeconservation.org/trap-tagger-about/">TrapTagger</a></li>
|
|
217
|
+
<li><a href="https://www.upperyellowstone.org/">Upper Yellowstone Watershed Group</a></li>
|
|
218
|
+
<li><a href="http://www.acmelab.ca/">Applied Conservation Macro Ecology Lab</a>, University of Victoria</li>
|
|
219
|
+
<li><a href="https://www.pc.gc.ca/en/pn-np/ab/banff/nature/conservation">Banff National Park Resource Conservation</a>, <a href="https://www.pc.gc.ca/en/pn-np/ab/banff/nature/conservation">Parks Canada</a></li>
|
|
220
|
+
<li><a href="https://blumsteinlab.eeb.ucla.edu/">Blumstein Lab</a>, UCLA</li>
|
|
221
|
+
<li><a href="https://bri.sulross.edu/">Borderlands Research Institute</a>, Sul Ross State University</li>
|
|
222
|
+
<li><a href="https://www.nps.gov/care/index.htm">Capitol Reef National Park</a> / Utah Valley University</li>
|
|
223
|
+
<li><a href="https://www.amnh.org/research/center-for-biodiversity-conservation">Center for Biodiversity and Conservation</a>, American Museum of Natural History</li>
|
|
224
|
+
<li><a href="https://www.unsw.edu.au/research/">Centre for Ecosystem Science</a>, UNSW Sydney</li>
|
|
225
|
+
<li><a href="https://crossculturalecology.net/">Cross-Cultural Ecology Lab</a>, Macquarie University</li>
|
|
226
|
+
<li><a href="https://hub.dccatcount.org/">DC Cat Count</a>, led by the Humane Rescue Alliance</li>
|
|
227
|
+
<li><a href="https://www.uidaho.edu/cnr/departments/fish-and-wildlife-sciences">Department of Fish and Wildlife Sciences</a>, University of Idaho</li>
|
|
228
|
+
<li><a href="https://wec.ifas.ufl.edu/">Department of Wildlife Ecology and Conservation</a>, University of Florida</li>
|
|
229
|
+
<li><a href="https://www.researchgate.net/lab/Fernanda-Michalski-Lab-4">Ecology and Conservation of Amazonian Vertebrates Research Group</a>, Federal University of Amapá</li>
|
|
230
|
+
<li><a href="https://www.rspb.org.uk/our-work/conservation/projects/scientific-support-for-the-gola-forest-programme/">Gola Forest Programme</a>, Royal Society for the Protection of Birds (RSPB)</li>
|
|
231
|
+
<li><a href="https://wildliferesearch.co.uk/group-1">Graeme Shannon's Research Group</a>, Bangor University</li>
|
|
232
|
+
<li><a href="https://hamaarag.org.il/">Hamaarag</a>, The Steinhardt Museum of Natural History, Tel Aviv University</li>
|
|
233
|
+
<li><a href="https://isfort.uqo.ca/">Institut des Science de la Forêt Tempérée (ISFORT)</a>, Université du Québec en Outaouais</li>
|
|
234
|
+
<li><a href="https://bhlab.in/about">Lab of Dr. Bilal Habib</a>, the Wildlife Institute of India</li>
|
|
235
|
+
<li><a href="https://labs.wsu.edu/dthornton/">Mammal Spatial Ecology and Conservation Lab</a>, Washington State University</li>
|
|
236
|
+
<li><a href="http://mcloughlinlab.ca/lab/">McLoughlin Lab in Population Ecology</a>, University of Saskatchewan</li>
|
|
237
|
+
<li><a href="https://www.fws.gov/about/region/southwest">National Wildlife Refuge System, Southwest Region</a>, U.S. Fish & Wildlife Service</li>
|
|
238
|
+
<li><a href="https://nationalzoo.si.edu/news/restoring-americas-prairie">Northern Great Plains Program</a>, Smithsonian</li>
|
|
239
|
+
<li><a href="https://depts.washington.edu/sefsqel/">Quantitative Ecology Lab</a>, University of Washington</li>
|
|
240
|
+
<li><a href="https://www.nps.gov/samo/index.htm">Santa Monica Mountains Recreation Area</a>, National Park Service</li>
|
|
241
|
+
<li><a href="https://www.zoo.org/seattlecarnivores">Seattle Urban Carnivore Project</a>, Woodland Park Zoo</li>
|
|
242
|
+
<li><a href="https://www.icmbio.gov.br/parnaserradosorgaos/">Serra dos Órgãos National Park</a>, ICMBio</li>
|
|
243
|
+
<li><a href="https://emammal.si.edu/snapshot-usa">Snapshot USA</a>, Smithsonian</li>
|
|
244
|
+
<li><a href="https://wildlife.forestry.ubc.ca/">Wildlife Coexistence Lab</a>, University of British Columbia</li>
|
|
245
|
+
<li><a href="https://www.dfw.state.or.us/wildlife/research/index.asp">Wildlife Research</a>, Oregon Department of Fish and Wildlife</li>
|
|
246
|
+
<li><a href="https://www.michigan.gov/dnr/about/contact/wildlife">Wildlife Division</a>, Michigan Department of Natural Resources</li>
|
|
247
|
+
<li>Department of Ecology, TU Berlin</li>
|
|
248
|
+
<li>Ghost Cat Analytics</li>
|
|
249
|
+
<li>Protected Areas Unit, Canadian Wildlife Service</li>
|
|
250
|
+
<li><a href="https://www.utas.edu.au/natural-sciences">School of Natural Sciences</a>, University of Tasmania (<a href="https://www.utas.edu.au/about/news-and-stories/articles/2022/1204-innovative-camera-network-keeps-close-eye-on-tassie-wildlife">story</a>)</li>
|
|
251
|
+
<li><a href="https://www.fws.gov/refuge/kenai">Kenai National Wildlife Refuge</a>, U.S. Fish & Wildlife Service (<a href="https://www.peninsulaclarion.com/sports/refuge-notebook-new-technology-increases-efficiency-of-refuge-cameras/">story</a>)</li>
|
|
252
|
+
<li><a href="https://www.australianwildlife.org/">Australian Wildlife Conservancy</a> (<a href="https://www.australianwildlife.org/cutting-edge-technology-delivering-efficiency-gains-in-conservation/">blog</a>, <a href="https://www.australianwildlife.org/efficiency-gains-at-the-cutting-edge-of-technology/">blog</a>)</li>
|
|
253
|
+
<li><a href="https://felidaefund.org/">Felidae Conservation Fund</a> (<a href="https://wildepod.org/">WildePod platform</a>) (<a href="https://abhaykashyap.com/blog/ai-powered-camera-trap-image-annotation-system/">blog post</a>)</li>
|
|
254
|
+
<li><a href="https://www.abmi.ca/home.html">Alberta Biodiversity Monitoring Institute (ABMI)</a> (<a href="https://www.wildtrax.ca/">WildTrax platform</a>) (<a href="https://wildcams.ca/blog/the-abmi-visits-the-zoo/">blog post</a>)</li>
|
|
255
|
+
<li><a href="http://en.shanshui.org/">Shan Shui Conservation Center</a> (<a href="https://mp.weixin.qq.com/s/iOIQF3ckj0-rEG4yJgerYw?fbclid=IwAR0alwiWbe3udIcFvqqwm7y5qgr9hZpjr871FZIa-ErGUukZ7yJ3ZhgCevs">blog post</a>) (<a href="https://mp-weixin-qq-com.translate.goog/s/iOIQF3ckj0-rEG4yJgerYw?fbclid=IwAR0alwiWbe3udIcFvqqwm7y5qgr9hZpjr871FZIa-ErGUukZ7yJ3ZhgCevs&_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp">translated blog post</a>)</li>
|
|
256
|
+
<li><a href="http://www.irconservancy.org/">Irvine Ranch Conservancy</a> (<a href="https://www.ocregister.com/2022/03/30/ai-software-is-helping-researchers-focus-on-learning-about-ocs-wild-animals/">story</a>)</li>
|
|
257
|
+
<li><a href="https://wildlifeprotectionsolutions.org/">Wildlife Protection Solutions</a> (<a href="https://customers.microsoft.com/en-us/story/1384184517929343083-wildlife-protection-solutions-nonprofit-ai-for-earth">story</a>, <a href="https://www.enterpriseai.news/2023/02/20/ai-helps-wildlife-protection-solutions-safeguard-endangered-species/">story</a>)</li>
|
|
258
|
+
<li><a href="https://roadecology.ucdavis.edu/">Road Ecology Center</a>, University of California, Davis (<a href="https://wildlifeobserver.net/">Wildlife Observer Network platform</a>)</li>
|
|
259
|
+
<li><a href="https://www.nature.org/en-us/about-us/where-we-work/united-states/california/">The Nature Conservancy in California</a> (<a href="https://github.com/tnc-ca-geo/animl-frontend">Animl platform</a>)</li>
|
|
260
|
+
<li><a href="https://science.sandiegozoo.org/">San Diego Zoo Wildlife Alliance</a> (<a href="https://github.com/conservationtechlab/animl">Animl R package</a>)</li>
|
|
261
|
+
</ul>
|
|
262
|
+
|
|
263
|
+
</details><br>
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
>[!IMPORTANT]
|
|
267
|
+
>If you would like to be added to this list or have any questions regarding MegaDetector and Pytorch-Wildlife, please [email us](zhongqimiao@microsoft.com) or join us in our Discord channel: [](https://discord.gg/TeEVxzaYtm)
|
|
268
|
+
|
|
@@ -45,7 +45,7 @@ class ImageFolder(Dataset):
|
|
|
45
45
|
self.transform = transform
|
|
46
46
|
self.images = [os.path.join(dp, f) for dp, dn, filenames in os.walk(image_dir) for f in filenames if is_image_file(f)] # dp: directory path, dn: directory name, f: filename
|
|
47
47
|
|
|
48
|
-
def __getitem__(self, idx):
|
|
48
|
+
def __getitem__(self, idx) -> tuple:
|
|
49
49
|
"""
|
|
50
50
|
Retrieves an image from the dataset.
|
|
51
51
|
|
|
@@ -57,7 +57,7 @@ class ImageFolder(Dataset):
|
|
|
57
57
|
"""
|
|
58
58
|
pass
|
|
59
59
|
|
|
60
|
-
def __len__(self):
|
|
60
|
+
def __len__(self) -> int:
|
|
61
61
|
"""
|
|
62
62
|
Returns the total number of images in the dataset.
|
|
63
63
|
|
|
@@ -83,7 +83,7 @@ class ClassificationImageFolder(ImageFolder):
|
|
|
83
83
|
"""
|
|
84
84
|
super(ClassificationImageFolder, self).__init__(image_dir, transform)
|
|
85
85
|
|
|
86
|
-
def __getitem__(self, idx):
|
|
86
|
+
def __getitem__(self, idx) -> tuple:
|
|
87
87
|
"""
|
|
88
88
|
Retrieves an image from the dataset.
|
|
89
89
|
|
|
@@ -123,7 +123,7 @@ class DetectionImageFolder(ImageFolder):
|
|
|
123
123
|
"""
|
|
124
124
|
super(DetectionImageFolder, self).__init__(image_dir, transform)
|
|
125
125
|
|
|
126
|
-
def __getitem__(self, idx):
|
|
126
|
+
def __getitem__(self, idx) -> tuple:
|
|
127
127
|
"""
|
|
128
128
|
Retrieves an image from the dataset.
|
|
129
129
|
|
|
@@ -155,7 +155,7 @@ class DetectionCrops(Dataset):
|
|
|
155
155
|
self.detection_results = detection_results
|
|
156
156
|
self.transform = transform
|
|
157
157
|
self.path_head = path_head
|
|
158
|
-
self.animal_cls_id = animal_cls_id # This
|
|
158
|
+
self.animal_cls_id = animal_cls_id # This determines which detection class id represents animals.
|
|
159
159
|
self.img_ids = []
|
|
160
160
|
self.xyxys = []
|
|
161
161
|
|
|
@@ -169,7 +169,7 @@ class DetectionCrops(Dataset):
|
|
|
169
169
|
self.img_ids.append(det["img_id"])
|
|
170
170
|
self.xyxys.append(xyxy)
|
|
171
171
|
|
|
172
|
-
def __getitem__(self, idx):
|
|
172
|
+
def __getitem__(self, idx) -> tuple:
|
|
173
173
|
"""
|
|
174
174
|
Retrieves an image from the dataset.
|
|
175
175
|
|
|
@@ -196,5 +196,5 @@ class DetectionCrops(Dataset):
|
|
|
196
196
|
|
|
197
197
|
return img, img_path
|
|
198
198
|
|
|
199
|
-
def __len__(self):
|
|
199
|
+
def __len__(self) -> int:
|
|
200
200
|
return len(self.img_ids)
|
|
@@ -15,27 +15,24 @@ __all__ = [
|
|
|
15
15
|
]
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
def letterbox(im, new_shape=(640, 640), color=(114, 114, 114), auto=False, scaleFill=False, scaleup=True, stride=32):
|
|
18
|
+
def letterbox(im, new_shape=(640, 640), color=(114, 114, 114), auto=False, scaleFill=False, scaleup=True, stride=32) -> torch.Tensor:
|
|
19
19
|
"""
|
|
20
|
-
Resize and pad an image to a desired shape while keeping the aspect ratio unchanged.
|
|
20
|
+
Resize and pad an image to a desired shape while keeping the aspect ratio unchanged.
|
|
21
21
|
|
|
22
22
|
This function is commonly used in object detection tasks to prepare images for models like YOLOv5.
|
|
23
23
|
It resizes the image to fit into the new shape with the correct aspect ratio and then pads the rest.
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
Args:
|
|
26
|
+
im (PIL.Image.Image or torch.Tensor): The input image. It can be a PIL image or a PyTorch tensor.
|
|
27
|
+
new_shape (tuple, optional): The target size of the image, in the form (height, width). Defaults to (640, 640).
|
|
28
|
+
color (tuple, optional): The color used for padding. Defaults to (114, 114, 114).
|
|
29
|
+
auto (bool, optional): Adjust padding to ensure the padded image dimensions are a multiple of the stride. Defaults to False.
|
|
30
|
+
scaleFill (bool, optional): If True, scales the image to fill the new shape, ignoring the aspect ratio. Defaults to False.
|
|
31
|
+
scaleup (bool, optional): Allow the function to scale up the image. Defaults to True.
|
|
32
|
+
stride (int, optional): The stride used in the model. The padding is adjusted to be a multiple of this stride. Defaults to 32.
|
|
33
33
|
|
|
34
34
|
Returns:
|
|
35
|
-
|
|
36
|
-
- The transformed image as a torch.Tensor.
|
|
37
|
-
- The scale ratios as a tuple (width_ratio, height_ratio).
|
|
38
|
-
- The padding applied as a tuple (width_padding, height_padding).
|
|
35
|
+
torch.Tensor: The transformed image with padding applied.
|
|
39
36
|
"""
|
|
40
37
|
|
|
41
38
|
# Convert PIL Image to Torch Tensor
|
|
@@ -99,7 +96,7 @@ class MegaDetector_v5_Transform:
|
|
|
99
96
|
self.target_size = target_size
|
|
100
97
|
self.stride = stride
|
|
101
98
|
|
|
102
|
-
def __call__(self, np_img):
|
|
99
|
+
def __call__(self, np_img) -> torch.Tensor:
|
|
103
100
|
"""
|
|
104
101
|
Applies the transformation on the provided image.
|
|
105
102
|
|
|
@@ -145,7 +142,7 @@ class Classification_Inference_Transform:
|
|
|
145
142
|
transforms.Normalize(self.mean, self.std)
|
|
146
143
|
])
|
|
147
144
|
|
|
148
|
-
def __call__(self, img):
|
|
145
|
+
def __call__(self, img) -> torch.Tensor:
|
|
149
146
|
"""
|
|
150
147
|
Applies the transformation on the provided image.
|
|
151
148
|
|
|
@@ -81,13 +81,13 @@ class AI4GAmazonRainforest(PlainResNetInference):
|
|
|
81
81
|
super(AI4GAmazonRainforest, self).__init__(weights=weights, device=device,
|
|
82
82
|
num_cls=36, num_layers=50, url=url)
|
|
83
83
|
|
|
84
|
-
def results_generation(self, logits, img_ids, id_strip=None):
|
|
84
|
+
def results_generation(self, logits: torch.Tensor, img_ids: list[str], id_strip: str = None) -> list[dict]:
|
|
85
85
|
"""
|
|
86
86
|
Generate results for classification.
|
|
87
87
|
|
|
88
88
|
Args:
|
|
89
89
|
logits (torch.Tensor): Output tensor from the model.
|
|
90
|
-
|
|
90
|
+
img_ids (str): Image identifier.
|
|
91
91
|
id_strip (str): stiping string for better image id saving.
|
|
92
92
|
|
|
93
93
|
Returns:
|
|
@@ -124,17 +124,17 @@ class PlainResNetInference(BaseClassifierInference):
|
|
|
124
124
|
else:
|
|
125
125
|
self.transform = pw_trans.Classification_Inference_Transform(target_size=self.IMAGE_SIZE)
|
|
126
126
|
|
|
127
|
-
def results_generation(self, logits,
|
|
127
|
+
def results_generation(self, logits: torch.Tensor, img_ids: list[str], id_strip: str = None) -> list[dict]:
|
|
128
128
|
"""
|
|
129
129
|
Process logits to produce final results.
|
|
130
130
|
|
|
131
131
|
Args:
|
|
132
132
|
logits (torch.Tensor): Logits from the network.
|
|
133
|
-
|
|
134
|
-
id_strip (str):
|
|
133
|
+
img_ids (list[str]): List of image paths.
|
|
134
|
+
id_strip (str): Stripping string for better image ID saving.
|
|
135
135
|
|
|
136
136
|
Returns:
|
|
137
|
-
dict:
|
|
137
|
+
list[dict]: List of dictionaries containing the results.
|
|
138
138
|
"""
|
|
139
139
|
pass
|
|
140
140
|
|
|
@@ -21,29 +21,29 @@ class CustomWeights(PlainResNetInference):
|
|
|
21
21
|
|
|
22
22
|
def __init__(self, weights=None, class_names=None, device="cpu"):
|
|
23
23
|
"""
|
|
24
|
-
Initialize the
|
|
24
|
+
Initialize the CustomWeights Classifier.
|
|
25
25
|
|
|
26
26
|
Args:
|
|
27
27
|
weights (str, optional): Path to the model weights. Defaults to None.
|
|
28
|
+
class_names (list[str]): List of class names for the classifier.
|
|
28
29
|
device (str, optional): Device for model inference. Defaults to "cpu".
|
|
29
|
-
pretrained (bool, optional): Whether to use pretrained weights. Defaults to True.
|
|
30
30
|
"""
|
|
31
31
|
self.CLASS_NAMES = class_names
|
|
32
32
|
self.num_cls = len(self.CLASS_NAMES)
|
|
33
33
|
super(CustomWeights, self).__init__(weights=weights, device=device,
|
|
34
34
|
num_cls=self.num_cls, num_layers=50, url=None)
|
|
35
35
|
|
|
36
|
-
def results_generation(self, logits, img_ids, id_strip=None):
|
|
36
|
+
def results_generation(self, logits: torch.Tensor, img_ids: list[str], id_strip: str = None) -> list[dict]:
|
|
37
37
|
"""
|
|
38
38
|
Generate results for classification.
|
|
39
39
|
|
|
40
40
|
Args:
|
|
41
41
|
logits (torch.Tensor): Output tensor from the model.
|
|
42
|
-
|
|
43
|
-
id_strip (str):
|
|
42
|
+
img_ids (list[str]): List of image identifiers.
|
|
43
|
+
id_strip (str): Stripping string for better image ID saving.
|
|
44
44
|
|
|
45
45
|
Returns:
|
|
46
|
-
dict:
|
|
46
|
+
list[dict]: List of dictionaries containing image ID, prediction, and confidence score.
|
|
47
47
|
"""
|
|
48
48
|
|
|
49
49
|
probs = torch.softmax(logits, dim=1)
|
|
@@ -43,13 +43,13 @@ class AI4GOpossum(PlainResNetInference):
|
|
|
43
43
|
super(AI4GOpossum, self).__init__(weights=weights, device=device,
|
|
44
44
|
num_cls=1, num_layers=50, url=url)
|
|
45
45
|
|
|
46
|
-
def results_generation(self, logits, img_ids, id_strip=None):
|
|
46
|
+
def results_generation(self, logits: torch.Tensor, img_ids: list[str], id_strip: str = None) -> list[dict]:
|
|
47
47
|
"""
|
|
48
48
|
Generate results for classification.
|
|
49
49
|
|
|
50
50
|
Args:
|
|
51
51
|
logits (torch.Tensor): Output tensor from the model.
|
|
52
|
-
|
|
52
|
+
img_ids (list): List of image identifier.
|
|
53
53
|
id_strip (str): stiping string for better image id saving.
|
|
54
54
|
|
|
55
55
|
Returns:
|
|
@@ -51,13 +51,13 @@ class AI4GSnapshotSerengeti(PlainResNetInference):
|
|
|
51
51
|
super(AI4GSnapshotSerengeti, self).__init__(weights=weights, device=device,
|
|
52
52
|
num_cls=10, num_layers=18, url=url)
|
|
53
53
|
|
|
54
|
-
def results_generation(self, logits, img_ids, id_strip=None):
|
|
54
|
+
def results_generation(self, logits: torch.Tensor, img_ids: list[str], id_strip: str = None) -> list[dict]:
|
|
55
55
|
"""
|
|
56
56
|
Generate results for classification.
|
|
57
57
|
|
|
58
58
|
Args:
|
|
59
59
|
logits (torch.Tensor): Output tensor from the model.
|
|
60
|
-
|
|
60
|
+
img_ids (str): Image identifier.
|
|
61
61
|
id_strip (str): stiping string for better image id saving.
|
|
62
62
|
|
|
63
63
|
Returns:
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
""" model class for loading the DFNE classifier. """
|
|
3
2
|
|
|
4
3
|
# Import libraries
|
|
@@ -102,17 +101,17 @@ class TIMM_BaseClassifierInference(BaseClassifierInference):
|
|
|
102
101
|
self.predictor.to(self.device)
|
|
103
102
|
self.eval()
|
|
104
103
|
|
|
105
|
-
def results_generation(self, logits, img_ids, id_strip=None):
|
|
104
|
+
def results_generation(self, logits: torch.Tensor, img_ids: list[str], id_strip: str = None) -> list[dict]:
|
|
106
105
|
"""
|
|
107
106
|
Generate results for classification.
|
|
108
107
|
|
|
109
108
|
Args:
|
|
110
109
|
logits (torch.Tensor): Output tensor from the model.
|
|
111
|
-
|
|
112
|
-
id_strip (str):
|
|
110
|
+
img_ids (list[str]): List of image identifiers.
|
|
111
|
+
id_strip (str): Stripping string for better image ID saving.
|
|
113
112
|
|
|
114
113
|
Returns:
|
|
115
|
-
dict:
|
|
114
|
+
list[dict]: List of dictionaries containing image ID, prediction, and confidence score.
|
|
116
115
|
"""
|
|
117
116
|
|
|
118
117
|
probs = torch.softmax(logits, dim=1)
|
{pytorchwildlife-1.2.2 → pytorchwildlife-1.2.4}/PytorchWildlife/models/detection/base_detector.py
RENAMED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
2
|
# Licensed under the MIT License.
|
|
4
3
|
|
|
@@ -51,24 +50,21 @@ class BaseDetector(nn.Module):
|
|
|
51
50
|
"""
|
|
52
51
|
pass
|
|
53
52
|
|
|
54
|
-
def results_generation(self, preds, img_id, id_strip=None):
|
|
53
|
+
def results_generation(self, preds, img_id: str, id_strip: str = None) -> dict:
|
|
55
54
|
"""
|
|
56
55
|
Generate results for detection based on model predictions.
|
|
57
|
-
|
|
56
|
+
|
|
58
57
|
Args:
|
|
59
|
-
preds (numpy.ndarray):
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
Image identifier.
|
|
63
|
-
id_strip (str, optional):
|
|
64
|
-
Strip specific characters from img_id. Defaults to None.
|
|
58
|
+
preds (numpy.ndarray): Model predictions.
|
|
59
|
+
img_id (str): Image identifier.
|
|
60
|
+
id_strip (str, optional): Strip specific characters from img_id. Defaults to None.
|
|
65
61
|
|
|
66
62
|
Returns:
|
|
67
63
|
dict: Dictionary containing image ID, detections, and labels.
|
|
68
64
|
"""
|
|
69
65
|
pass
|
|
70
66
|
|
|
71
|
-
def single_image_detection(self, img, img_size=None, img_path=None, conf_thres=0.2, id_strip=None):
|
|
67
|
+
def single_image_detection(self, img, img_size=None, img_path=None, conf_thres=0.2, id_strip=None) -> dict:
|
|
72
68
|
"""
|
|
73
69
|
Perform detection on a single image.
|
|
74
70
|
|
|
@@ -89,19 +85,16 @@ class BaseDetector(nn.Module):
|
|
|
89
85
|
"""
|
|
90
86
|
pass
|
|
91
87
|
|
|
92
|
-
def batch_image_detection(self, dataloader, conf_thres=0.2, id_strip=None):
|
|
88
|
+
def batch_image_detection(self, dataloader, conf_thres: float = 0.2, id_strip: str = None) -> list[dict]:
|
|
93
89
|
"""
|
|
94
90
|
Perform detection on a batch of images.
|
|
95
|
-
|
|
91
|
+
|
|
96
92
|
Args:
|
|
97
|
-
dataloader (DataLoader):
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
Confidence threshold for predictions. Defaults to 0.2.
|
|
101
|
-
id_strip (str, optional):
|
|
102
|
-
Characters to strip from img_id. Defaults to None.
|
|
93
|
+
dataloader (DataLoader): DataLoader containing image batches.
|
|
94
|
+
conf_thres (float, optional): Confidence threshold for predictions. Defaults to 0.2.
|
|
95
|
+
id_strip (str, optional): Characters to strip from img_id. Defaults to None.
|
|
103
96
|
|
|
104
97
|
Returns:
|
|
105
|
-
list: List of detection results for all images.
|
|
98
|
+
list[dict]: List of detection results for all images.
|
|
106
99
|
"""
|
|
107
100
|
pass
|
|
@@ -164,16 +164,16 @@ class HerdNetLMDS(LMDS):
|
|
|
164
164
|
self.up = up
|
|
165
165
|
|
|
166
166
|
def __call__(self, outputs: List[torch.Tensor]) -> Tuple[list, list, list, list, list]:
|
|
167
|
-
|
|
167
|
+
"""
|
|
168
168
|
Args:
|
|
169
|
-
|
|
170
|
-
- heatmap: [B,1,H,W],
|
|
171
|
-
- class map: [B,C,H/16,W/16]
|
|
172
|
-
|
|
169
|
+
outputs (List[torch.Tensor]): Outputs of HerdNet, i.e., 2 tensors:
|
|
170
|
+
- heatmap: [B,1,H,W],
|
|
171
|
+
- class map: [B,C,H/16,W/16].
|
|
172
|
+
|
|
173
173
|
Returns:
|
|
174
|
-
Tuple[list,list,list,list,list]
|
|
175
|
-
|
|
176
|
-
|
|
174
|
+
Tuple[list, list, list, list, list]:
|
|
175
|
+
Counts, locations, labels, class scores, and detection scores per batch.
|
|
176
|
+
"""
|
|
177
177
|
|
|
178
178
|
heatmap, clsmap = outputs
|
|
179
179
|
|