PytorchWildlife 1.2.0__tar.gz → 1.2.2__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.0/PytorchWildlife.egg-info → pytorchwildlife-1.2.2}/PKG-INFO +87 -22
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/data/datasets.py +79 -9
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/data/transforms.py +3 -2
- pytorchwildlife-1.2.2/PytorchWildlife/models/classification/__init__.py +3 -0
- pytorchwildlife-1.2.2/PytorchWildlife/models/classification/base_classifier.py +28 -0
- {PytorchWildlife-1.2.0/PytorchWildlife/models/classification/resnet → pytorchwildlife-1.2.2/PytorchWildlife/models/classification/resnet_base}/base_classifier.py +25 -3
- pytorchwildlife-1.2.2/PytorchWildlife/models/classification/timm_base/DFNE.py +56 -0
- pytorchwildlife-1.2.2/PytorchWildlife/models/classification/timm_base/Deepfaune.py +47 -0
- pytorchwildlife-1.2.2/PytorchWildlife/models/classification/timm_base/__init__.py +3 -0
- pytorchwildlife-1.2.2/PytorchWildlife/models/classification/timm_base/base_classifier.py +212 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/detection/herdnet/herdnet.py +37 -8
- pytorchwildlife-1.2.2/PytorchWildlife/models/detection/ultralytics_based/Deepfaune.py +45 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/detection/ultralytics_based/__init__.py +2 -1
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/detection/ultralytics_based/megadetectorv5.py +5 -1
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/detection/ultralytics_based/yolov5_base.py +14 -7
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/detection/ultralytics_based/yolov8_base.py +14 -7
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/utils/post_process.py +22 -9
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2/PytorchWildlife.egg-info}/PKG-INFO +87 -22
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife.egg-info/SOURCES.txt +12 -6
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife.egg-info/requires.txt +2 -2
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/README.md +72 -18
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/setup.py +3 -3
- PytorchWildlife-1.2.0/PytorchWildlife/models/classification/__init__.py +0 -1
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/LICENSE +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PW_FT_classification/__init__.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PW_FT_classification/main.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/__init__.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/data/__init__.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/__init__.py +0 -0
- {PytorchWildlife-1.2.0/PytorchWildlife/models/classification/resnet → pytorchwildlife-1.2.2/PytorchWildlife/models/classification/resnet_base}/__init__.py +0 -0
- {PytorchWildlife-1.2.0/PytorchWildlife/models/classification/resnet → pytorchwildlife-1.2.2/PytorchWildlife/models/classification/resnet_base}/amazon.py +0 -0
- {PytorchWildlife-1.2.0/PytorchWildlife/models/classification/resnet → pytorchwildlife-1.2.2/PytorchWildlife/models/classification/resnet_base}/custom_weights.py +0 -0
- {PytorchWildlife-1.2.0/PytorchWildlife/models/classification/resnet → pytorchwildlife-1.2.2/PytorchWildlife/models/classification/resnet_base}/opossum.py +0 -0
- {PytorchWildlife-1.2.0/PytorchWildlife/models/classification/resnet → pytorchwildlife-1.2.2/PytorchWildlife/models/classification/resnet_base}/serengeti.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/detection/__init__.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/detection/base_detector.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/detection/herdnet/__init__.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/detection/herdnet/animaloc/__init__.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/detection/herdnet/animaloc/data/__init__.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/detection/herdnet/animaloc/data/patches.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/detection/herdnet/animaloc/data/types.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/detection/herdnet/animaloc/eval/__init__.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/detection/herdnet/animaloc/eval/lmds.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/detection/herdnet/animaloc/eval/stitchers.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/detection/herdnet/dla.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/detection/herdnet/model.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/models/detection/ultralytics_based/megadetectorv6.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/utils/__init__.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife/utils/misc.py +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife.egg-info/dependency_links.txt +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/PytorchWildlife.egg-info/top_level.txt +0 -0
- {PytorchWildlife-1.2.0 → pytorchwildlife-1.2.2}/setup.cfg +0 -0
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PytorchWildlife
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: a PyTorch Collaborative Deep Learning Framework for Conservation.
|
|
5
5
|
Home-page: https://github.com/microsoft/CameraTraps/
|
|
6
6
|
Author: Andres Hernandez, Zhongqi Miao, Daniela Ruiz Lopez, Isai Daniel Chacon Silva
|
|
7
7
|
Author-email: v-herandres@microsoft.com, zhongqimiao@microsoft.com, v-druizlopez@microsoft.com, v-ichaconsil@microsoft.com
|
|
8
8
|
License: MIT
|
|
9
9
|
Keywords: pytorch_wildlife,pytorch,wildlife,megadetector,conservation,animal,detection,classification
|
|
10
|
-
Platform: UNKNOWN
|
|
11
10
|
Classifier: Development Status :: 3 - Alpha
|
|
12
11
|
Classifier: Intended Audience :: Developers
|
|
13
12
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -15,6 +14,20 @@ Classifier: Programming Language :: Python :: 3
|
|
|
15
14
|
Requires-Python: >=3.8
|
|
16
15
|
Description-Content-Type: text/markdown
|
|
17
16
|
License-File: LICENSE
|
|
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
|
|
18
31
|
|
|
19
32
|

|
|
20
33
|
|
|
@@ -58,29 +71,60 @@ For those interested in accessing the previous MegaDetector repository, which ut
|
|
|
58
71
|
|
|
59
72
|
## 📣 Announcements
|
|
60
73
|
|
|
74
|
+
### Pytorch-Wildlife Version 1.2.1
|
|
75
|
+
|
|
76
|
+
#### SpeciesNet is available in Pytorch-Wildlife for testing!
|
|
77
|
+
- We have added SpeciesNet into our model zoo, which is compatible with all detection models provided by Pytorch-Wildlife. Please refer to [this document](https://github.com/microsoft/CameraTraps/blob/SppNet_TF/PytorchWildlife/models/classification/speciesnet_base/sppnet_readme.md) for more details!
|
|
78
|
+
|
|
79
|
+
#### Deepfaune in Our Model Zoo!!
|
|
80
|
+
- We are excited to announce the release of the Deepfaune models—both the detector and classifier—in PyTorch-Wildlife, adding to our growing model zoo. A huge thank you to the Deepfaune team for your support! Deepfaune is one of the most comprehensive models focused on the European ecosystem for both detection and classification. It serves as a great complement to MegaDetector, which has primarily been trained on datasets from North America, South America, and Africa. The Deepfaune detector is also our first third-party camera trap detection model integrated into PyTorch-Wildlife!
|
|
81
|
+
- To use the model, you just need to load them as any other Pytorch-Wildife models:
|
|
82
|
+
```
|
|
83
|
+
detection_model = pw_detection.DeepfauneDetector(device=DEVICE)
|
|
84
|
+
classification_model = pw_classification.DeepfauneClassifier(device=DEVICE)
|
|
85
|
+
```
|
|
86
|
+
- You can also use the `detection_classification_pipeline_demo.py` script in the demo folder to test the whole detection + classification pipeline.
|
|
87
|
+
- Please also take a look at the original [Deepfaune website](https://www.deepfaune.cnrs.fr/en/) and give them a star!
|
|
88
|
+
|
|
89
|
+
#### Deepfaune-New-England in Our Model Zoo Too!!
|
|
90
|
+
- Besides the original Deepfaune mode, there is another fine-tuned Deepfaune model developed by USGS for the Northeastern NA area called Deepfaune-New-England (DFNE). It can also be loaded with `classification_model = pw_classification.DFNE(device=DEVICE)`
|
|
91
|
+
- Please take a look at the orignal [DFNE repo](https://code.usgs.gov/vtcfwru/deepfaune-new-england/-/tree/main?ref_type=heads) and give them a star!
|
|
92
|
+
|
|
61
93
|
### Pytorch-Wildlife Version 1.2.0
|
|
62
|
-
-
|
|
63
|
-
- We have also released additional MegaDetectorV6 models based on Yolo-v10 and RtDetr. We have skipped Yolo-v11 models because of limited performance and architectural gains. Most of t whe MIT and Apache versions have also finished training but are waiting for internal review before they can be released.
|
|
64
|
-
- We have also updated our AI4G-Amazon model with bigger datasets and it has a better performance compared to previous iterations. Please feel free to test it or fine-tune on it.
|
|
65
|
-
- We will also make a new roadmap for 2025 in the next couple of updates.
|
|
94
|
+
- [What's New](ANNOUNCEMENT.md)
|
|
66
95
|
|
|
67
96
|
|
|
68
|
-
### :racing_car::dash::dash: MegaDetectorV6: SMALLER, BETTER, FASTER!
|
|
69
|
-
We have officially released our 6th version of MegaDetector, MegaDetectorV6! In the next generation of MegaDetector, we are focusing on computational efficiency, performance, mordernizing of model architectures, and licensing. We have trained multiple new models using different model architectures, including Yolo-v9, Yolo-v10, and RT-Detr for maximum user flexibility. We have a [rolling release schedule](#mag-model-zoo-and-release-schedules) for different versions of MegaDetectorV6.
|
|
70
97
|
|
|
71
|
-
|
|
98
|
+
### :racing_car::dash::dash: MegaDetectorV6: SMALLER, FASTER, BETTER!
|
|
99
|
+
We have officially released our 6th version of MegaDetector, MegaDetectorV6! In the next generation of MegaDetector, we are focusing on computational efficiency, performance, modernizing of model architectures, and licensing. We have trained multiple new models using different model architectures, including Yolo-v9, Yolo-v10, and RT-Detr for maximum user flexibility. We have a [rolling release schedule](#mag-model-zoo-and-release-schedules) for different versions of MegaDetectorV6.
|
|
72
100
|
|
|
73
|
-
!
|
|
101
|
+
>[!NOTE]
|
|
102
|
+
> - Following our initial release, we’ve been delighted to see so many people explore our new models. We’d like to extend our heartfelt thanks to everyone who has shown interest in our latest models—your support means a great deal to us!
|
|
103
|
+
> - That said, we’ve received a number of feedback comments highlighting a discrepancy between the reported performance (particularly MDV5) and the actual performance observed. We are actively investigating this issue and have identified a potential error or corruption in the validation data we used. For the time being, we’ll remove our current performance numbers from the model zoo for now to avoid confusion.
|
|
104
|
+
> - We sincerely apologize for any confusion or inconvenience this may have caused. Our team is working diligently to address this matter, and we will update our experiments—and potentially retrain the model if data corruption is confirmed—as soon as possible. Thank you for your patience and understanding!
|
|
74
105
|
|
|
75
|
-
>[!TIP]
|
|
76
|
-
>From now on, we encourage our users to use MegaDetectorV6 as their default animal detection model and choose whichever model that fits the project needs. To reduce potential confusion, we have also standardized the model names into MDV6-Compact and MDV6-Extra for two model sizes using the same architecture. Learn how to use MegaDetectorV6 in our [image demo](demo/image_detection_demo_v6.ipynb) and [video demo](demo/video_detection_demo_v6.ipynb).
|
|
77
106
|
|
|
78
107
|
|
|
79
|
-
|
|
108
|
+
MegaDetectorV6 models are based on architectures optimized for performance and low-budget devices. For example, the MegaDetectorV6-Ultralytics-YoloV10-Compact (MDV6-yolov10-c) model only have ***2% of the parameters*** of the previous MegaDetectorV5 and still exhibits comparable animal recall on our validation datasets.
|
|
109
|
+
|
|
110
|
+
<!-- In the following figure, we can see the Performance to Parameter metric of each released MegaDetector model. All of the V6 models, extra large or compact, have at least 50% less parameters compared to MegaDetectorV5 but with much higher animal detection performance. -->
|
|
111
|
+
|
|
112
|
+
<!--  -->
|
|
113
|
+
|
|
114
|
+
<!-- >[!TIP] -->
|
|
115
|
+
<!-- >From now on, we encourage our users to use MegaDetectorV6 as their default animal detection model and choose whichever model that fits the project needs. To reduce potential confusion, we have also standardized the model names into MDV6-Compact and MDV6-Extra for two model sizes using the same architecture. Learn how to use MegaDetectorV6 in our [image demo](demo/image_detection_demo_v6.ipynb) and [video demo](demo/video_detection_demo_v6.ipynb). -->
|
|
80
116
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
117
|
+
|
|
118
|
+
### :bangbang: Model licensing
|
|
119
|
+
|
|
120
|
+
The **Pytorch-Wildlife** package is under MIT, however some of the models in the model zoo are not. For example, MegaDetectorV5, which is trained using the Ultralytics package, a package under AGPL-3.0, and is not for closed-source commercial uses if they are using updated 'ultralytics' packages.
|
|
121
|
+
|
|
122
|
+
There may be a confusion because YOLOv5 was initially released before the establishment of the AGPL-3.0 license. According to the official [Ultralytics-Yolov5](https://github.com/ultralytics/yolov5) package, it is under AGPL-3.0 now, and the maintainers have discussed how their licensing policy has evolved over time in their issues section.
|
|
123
|
+
|
|
124
|
+
<!-- We aim to prevent any confusion or potential issues for our users. -->
|
|
125
|
+
|
|
126
|
+
<!-- > [!IMPORTANT]
|
|
127
|
+
> THIS IS TRUE TO ALL EXISTING MEGADETECTORV5 MODELS IN ALL EXISTING FORKS THAT ARE TRAINED USING YOLOV5, AN ULTRALYTICS-DEVELOPED MODEL. -->
|
|
84
128
|
|
|
85
129
|
We want to make Pytorch-Wildlife a platform where different models with different licenses can be hosted and want to enable different use cases. To reduce user confusions, in our [model zoo](#mag-model-zoo-and-release-schedules) section, we list all existing and planed future models in our model zoo, their corresponding license, and release schedules.
|
|
86
130
|
|
|
@@ -89,7 +133,22 @@ In addition, since the **Pytorch-Wildlife** package is under MIT, all the utilit
|
|
|
89
133
|
### :mag: Model Zoo and Release Schedules
|
|
90
134
|
|
|
91
135
|
#### MegaDetectors
|
|
92
|
-
|Models|Version Names|Licence|Release|Parameters (M)|
|
|
136
|
+
|Models|Version Names|Licence|Release|Parameters (M)|
|
|
137
|
+
|---|---|---|---|---|
|
|
138
|
+
|MegaDetectorV5|-|AGPL-3.0|Released|121|
|
|
139
|
+
|MegaDetectorV6-Ultralytics-YoloV9-Compact|MDV6-yolov9-c|AGPL-3.0|Released|25.5|
|
|
140
|
+
|MegaDetectorV6-Ultralytics-YoloV9-Extra|MDV6-yolov9-e|AGPL-3.0|Released|58.1|
|
|
141
|
+
|MegaDetectorV6-Ultralytics-YoloV10-Compact (even smaller and no NMS)|MDV6-yolov10-c|AGPL-3.0|Released|2.3|
|
|
142
|
+
|MegaDetectorV6-Ultralytics-YoloV10-Extra (extra large model and no NMS)|MDV6-yolov10-c|AGPL-3.0|Released|29.5|
|
|
143
|
+
|MegaDetectorV6-Ultralytics-RtDetr-Compact|MDV6-redetr-c|AGPL-3.0|Released|31.9|
|
|
144
|
+
|MegaDetectorV6-Ultralytics-YoloV11-Compact|-|AGPL-3.0|Will Not Release|2.6|
|
|
145
|
+
|MegaDetectorV6-Ultralytics-YoloV11-Extra|-|AGPL-3.0|Will Not Release|56.9|
|
|
146
|
+
|MegaDetectorV6-MIT-YoloV9-Compact|MDV6-mit-yolov9-c|MIT|Training|9.7|
|
|
147
|
+
|MegaDetectorV6-MIT-YoloV9-Extra|MDV6-mit-yolov9-c|MIT|Training|51|
|
|
148
|
+
|MegaDetectorV6-Apache-RTDetr-Compact|MDV6-apa-redetr-c|Apache|Training|20|
|
|
149
|
+
|MegaDetectorV6-Apache-RTDetr-Extra|MDV6-apa-redetr-c|Apache|Training|76|
|
|
150
|
+
|
|
151
|
+
<!-- |Models|Version Names|Licence|Release|Parameters (M)|mAP<sup>val<br>50-95|Animal Recall|
|
|
93
152
|
|---|---|---|---|---|---|---|
|
|
94
153
|
|MegaDetectorV5|-|AGPL-3.0|Released|121|74.7|74.9|
|
|
95
154
|
|MegaDetectorV6-Ultralytics-YoloV9-Compact|MDV6-yolov9-c|AGPL-3.0|Released|25.5|73.8|82.6|
|
|
@@ -102,11 +161,17 @@ In addition, since the **Pytorch-Wildlife** package is under MIT, all the utilit
|
|
|
102
161
|
|MegaDetectorV6-MIT-YoloV9-Compact|MDV6-mit-yolov9-c|MIT|MDV6-mit-yolov9-c|February 2025|9.7|73.84|-|
|
|
103
162
|
|MegaDetectorV6-MIT-YoloV9-Extra|MDV6-mit-yolov9-c|MIT|February 2025|51|Training|Training|
|
|
104
163
|
|MegaDetectorV6-Apache-RTDetr-Compact|MDV6-apa-redetr-c|Apache|February 2025|20|76.3|-|
|
|
105
|
-
|MegaDetectorV6-Apache-RTDetr-Extra|MDV6-apa-redetr-c|Apache|February 2025|76|80.8|-|
|
|
164
|
+
|MegaDetectorV6-Apache-RTDetr-Extra|MDV6-apa-redetr-c|Apache|February 2025|76|80.8|-| -->
|
|
165
|
+
|
|
166
|
+
> [!TIP]
|
|
167
|
+
> We are specifically reporting `Animal Recall` as our primary performance metric, even though it is not commonly used in traditional object detection studies, which typically focus on balancing overall model performance. For MegaDetector, our goal is to optimize for animal recall—in other words, minimizing false negative detections of animals or, more simply, ensuring our model misses as few animals as possible. While this may result in a higher false positive rate, we rely on downstream classification models to further filter the detected objects. We believe this approach is more practical for real-world animal monitoring scenarios.
|
|
168
|
+
|
|
169
|
+
|
|
106
170
|
|
|
107
171
|
#### Other detection models
|
|
108
172
|
|Models|Version Names|Licence|Release|Reference|
|
|
109
173
|
|---|---|---|---|---|
|
|
174
|
+
|Deepfaune-detection|-|CC BY-SA 4.0|Released|[Deepfaune](https://www.deepfaune.cnrs.fr/en/)|
|
|
110
175
|
|HerdNet-general|general|CC BY-NC-SA-4.0|Released|[Alexandre et. al. 2023](https://github.com/Alexandre-Delplanque/HerdNet)|
|
|
111
176
|
|HerdNet-ennedi|ennedi|CC BY-NC-SA-4.0|Released|[Alexandre et. al. 2023](https://github.com/Alexandre-Delplanque/HerdNet)|
|
|
112
177
|
|MegaDetector-Overhead|-|MIT|Mid 2025|-|
|
|
@@ -119,6 +184,8 @@ In addition, since the **Pytorch-Wildlife** package is under MIT, all the utilit
|
|
|
119
184
|
|AI4G-Amazon-V1|v1|MIT|Released|
|
|
120
185
|
|AI4G-Amazon-V2|v2|MIT|Released|
|
|
121
186
|
|AI4G-Serengeti|-|MIT|Released|
|
|
187
|
+
|Deepfaune-classification|v1.3|CC BY-SA 4.0|Released|[Deepfaune](https://www.deepfaune.cnrs.fr/en/)|
|
|
188
|
+
|Deepfaune-New-England|v1.0|CC0 1.0 Universal|Released|[Deepfaune-New-England](https://code.usgs.gov/vtcfwru/deepfaune-new-england)|
|
|
122
189
|
|
|
123
190
|
>[!TIP]
|
|
124
191
|
>Some models, such as MegaDetectorV6, HerdNet, and AI4G-Amazon, have different versions, and they are loaded by their corresponding version names. Here is an example: `detection_model = pw_detection.MegaDetectorV6(version="MDV6-yolov10-e")`.
|
|
@@ -214,8 +281,8 @@ Let's shape the future of wildlife research, together! 🙌
|
|
|
214
281
|
*Credits to the Agency for Regulation and Control of Biosecurity and Quarantine for Galápagos (ABG), Ecuador.*
|
|
215
282
|
|
|
216
283
|
|
|
217
|
-
## 🤜🤛 Collaboration with EcoAssist!
|
|
218
|
-
We are thrilled to announce our collaboration with [
|
|
284
|
+
## 🤜🤛 Collaboration with AddaxAI (formerly EcoAssist)!
|
|
285
|
+
We are thrilled to announce our collaboration with [AddaxAI](https://addaxdatascience.com/addaxai/#spp-models)---a powerful user interface software that enables users to directly load models from the PyTorch-Wildlife model zoo for image analysis on local computers. With AddaxAI, you can now utilize MegaDetectorV5 and the classification models---AI4GAmazonRainforest and AI4GOpossum---for automatic animal detection and identification, alongside a comprehensive suite of pre- and post-processing tools. This partnership aims to enhance the overall user experience with PyTorch-Wildlife models for a general audience. We will work closely to bring more features together for more efficient and effective wildlife analysis in the future.
|
|
219
286
|
|
|
220
287
|
|
|
221
288
|
## :fountain_pen: Cite us!
|
|
@@ -393,5 +460,3 @@ Protected Areas Unit, Canadian Wildlife Service
|
|
|
393
460
|
>[!IMPORTANT]
|
|
394
461
|
>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)
|
|
395
462
|
|
|
396
|
-
|
|
397
|
-
|
|
@@ -25,7 +25,7 @@ def is_image_file(filename: str) -> bool:
|
|
|
25
25
|
"""Checks if a file is an allowed image extension."""
|
|
26
26
|
return has_file_allowed_extension(filename, IMG_EXTENSIONS)
|
|
27
27
|
|
|
28
|
-
class
|
|
28
|
+
class ImageFolder(Dataset):
|
|
29
29
|
"""
|
|
30
30
|
A PyTorch Dataset for loading images from a specified directory.
|
|
31
31
|
Each item in the dataset is a tuple containing the image data,
|
|
@@ -40,11 +40,49 @@ class DetectionImageFolder(Dataset):
|
|
|
40
40
|
image_dir (str): Path to the directory containing the images.
|
|
41
41
|
transform (callable, optional): Optional transform to be applied on the image.
|
|
42
42
|
"""
|
|
43
|
-
super(
|
|
43
|
+
super(ImageFolder, self).__init__()
|
|
44
44
|
self.image_dir = image_dir
|
|
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):
|
|
49
|
+
"""
|
|
50
|
+
Retrieves an image from the dataset.
|
|
51
|
+
|
|
52
|
+
Parameters:
|
|
53
|
+
idx (int): Index of the image to retrieve.
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
tuple: Contains the image data, the image's path, and its original size.
|
|
57
|
+
"""
|
|
58
|
+
pass
|
|
59
|
+
|
|
60
|
+
def __len__(self):
|
|
61
|
+
"""
|
|
62
|
+
Returns the total number of images in the dataset.
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
int: Total number of images.
|
|
66
|
+
"""
|
|
67
|
+
return len(self.images)
|
|
68
|
+
|
|
69
|
+
class ClassificationImageFolder(ImageFolder):
|
|
70
|
+
"""
|
|
71
|
+
A PyTorch Dataset for loading images from a specified directory.
|
|
72
|
+
Each item in the dataset is a tuple containing the image data,
|
|
73
|
+
the image's path, and the original size of the image.
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
def __init__(self, image_dir, transform=None):
|
|
77
|
+
"""
|
|
78
|
+
Initializes the dataset.
|
|
79
|
+
|
|
80
|
+
Parameters:
|
|
81
|
+
image_dir (str): Path to the directory containing the images.
|
|
82
|
+
transform (callable, optional): Optional transform to be applied on the image.
|
|
83
|
+
"""
|
|
84
|
+
super(ClassificationImageFolder, self).__init__(image_dir, transform)
|
|
85
|
+
|
|
48
86
|
def __getitem__(self, idx):
|
|
49
87
|
"""
|
|
50
88
|
Retrieves an image from the dataset.
|
|
@@ -60,22 +98,54 @@ class DetectionImageFolder(Dataset):
|
|
|
60
98
|
|
|
61
99
|
# Load and convert image to RGB
|
|
62
100
|
img = Image.open(img_path).convert("RGB")
|
|
63
|
-
img_size_ori = img.size[::-1]
|
|
64
101
|
|
|
65
102
|
# Apply transformation if specified
|
|
66
103
|
if self.transform:
|
|
67
104
|
img = self.transform(img)
|
|
68
105
|
|
|
69
|
-
return img, img_path
|
|
70
|
-
|
|
71
|
-
|
|
106
|
+
return img, img_path
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class DetectionImageFolder(ImageFolder):
|
|
110
|
+
"""
|
|
111
|
+
A PyTorch Dataset for loading images from a specified directory.
|
|
112
|
+
Each item in the dataset is a tuple containing the image data,
|
|
113
|
+
the image's path, and the original size of the image.
|
|
114
|
+
"""
|
|
115
|
+
|
|
116
|
+
def __init__(self, image_dir, transform=None):
|
|
72
117
|
"""
|
|
73
|
-
|
|
118
|
+
Initializes the dataset.
|
|
119
|
+
|
|
120
|
+
Parameters:
|
|
121
|
+
image_dir (str): Path to the directory containing the images.
|
|
122
|
+
transform (callable, optional): Optional transform to be applied on the image.
|
|
123
|
+
"""
|
|
124
|
+
super(DetectionImageFolder, self).__init__(image_dir, transform)
|
|
125
|
+
|
|
126
|
+
def __getitem__(self, idx):
|
|
127
|
+
"""
|
|
128
|
+
Retrieves an image from the dataset.
|
|
129
|
+
|
|
130
|
+
Parameters:
|
|
131
|
+
idx (int): Index of the image to retrieve.
|
|
74
132
|
|
|
75
133
|
Returns:
|
|
76
|
-
|
|
134
|
+
tuple: Contains the image data, the image's path, and its original size.
|
|
77
135
|
"""
|
|
78
|
-
|
|
136
|
+
# Get image filename and path
|
|
137
|
+
img_path = self.images[idx]
|
|
138
|
+
|
|
139
|
+
# Load and convert image to RGB
|
|
140
|
+
img = Image.open(img_path).convert("RGB")
|
|
141
|
+
img_size_ori = img.size[::-1]
|
|
142
|
+
|
|
143
|
+
# Apply transformation if specified
|
|
144
|
+
if self.transform:
|
|
145
|
+
img = self.transform(img)
|
|
146
|
+
|
|
147
|
+
return img, img_path, torch.tensor(img_size_ori)
|
|
148
|
+
|
|
79
149
|
|
|
80
150
|
# TODO: Under development for efficiency improvement
|
|
81
151
|
class DetectionCrops(Dataset):
|
|
@@ -130,7 +130,7 @@ class Classification_Inference_Transform:
|
|
|
130
130
|
mean = [0.485, 0.456, 0.406]
|
|
131
131
|
std = [0.229, 0.224, 0.225]
|
|
132
132
|
|
|
133
|
-
def __init__(self, target_size=224):
|
|
133
|
+
def __init__(self, target_size=224, **kwargs):
|
|
134
134
|
"""
|
|
135
135
|
Initializes the transform.
|
|
136
136
|
|
|
@@ -139,7 +139,8 @@ class Classification_Inference_Transform:
|
|
|
139
139
|
"""
|
|
140
140
|
# Define the sequence of transformations
|
|
141
141
|
self.trans = transforms.Compose([
|
|
142
|
-
transforms.Resize((target_size, target_size)),
|
|
142
|
+
# transforms.Resize((target_size, target_size)),
|
|
143
|
+
transforms.Resize((target_size, target_size), **kwargs),
|
|
143
144
|
transforms.ToTensor(),
|
|
144
145
|
transforms.Normalize(self.mean, self.std)
|
|
145
146
|
])
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
# Licensed under the MIT License.
|
|
4
|
+
|
|
5
|
+
import torch.nn as nn
|
|
6
|
+
|
|
7
|
+
# Making the PlainResNetInference class available for import from this module
|
|
8
|
+
__all__ = ["BaseClassifierInference"]
|
|
9
|
+
|
|
10
|
+
class BaseClassifierInference(nn.Module):
|
|
11
|
+
"""
|
|
12
|
+
Inference module for the PlainResNet Classifier.
|
|
13
|
+
"""
|
|
14
|
+
def __init__(self):
|
|
15
|
+
super(BaseClassifierInference, self).__init__()
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
def results_generation(self):
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
def forward(self):
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
def single_image_classification(self):
|
|
25
|
+
pass
|
|
26
|
+
|
|
27
|
+
def batch_image_classification(self):
|
|
28
|
+
pass
|
|
@@ -10,8 +10,11 @@ import torch
|
|
|
10
10
|
import torch.nn as nn
|
|
11
11
|
from torchvision.models.resnet import BasicBlock, Bottleneck, ResNet
|
|
12
12
|
from torch.hub import load_state_dict_from_url
|
|
13
|
+
from torch.utils.data import DataLoader
|
|
13
14
|
|
|
15
|
+
from ..base_classifier import BaseClassifierInference
|
|
14
16
|
from ....data import transforms as pw_trans
|
|
17
|
+
from ....data import datasets as pw_data
|
|
15
18
|
|
|
16
19
|
# Making the PlainResNetInference class available for import from this module
|
|
17
20
|
__all__ = ["PlainResNetInference"]
|
|
@@ -97,10 +100,11 @@ class PlainResNetClassifier(nn.Module):
|
|
|
97
100
|
print("unused_keys:", sorted(list(unused_keys)))
|
|
98
101
|
|
|
99
102
|
|
|
100
|
-
class PlainResNetInference(
|
|
103
|
+
class PlainResNetInference(BaseClassifierInference):
|
|
101
104
|
"""
|
|
102
105
|
Inference module for the PlainResNet Classifier.
|
|
103
106
|
"""
|
|
107
|
+
IMAGE_SIZE = None
|
|
104
108
|
def __init__(self, num_cls=36, num_layers=50, weights=None, device="cpu", url=None, transform=None):
|
|
105
109
|
super(PlainResNetInference, self).__init__()
|
|
106
110
|
self.device = device
|
|
@@ -118,7 +122,7 @@ class PlainResNetInference(nn.Module):
|
|
|
118
122
|
if transform:
|
|
119
123
|
self.transform = transform
|
|
120
124
|
else:
|
|
121
|
-
self.transform = pw_trans.Classification_Inference_Transform(target_size=
|
|
125
|
+
self.transform = pw_trans.Classification_Inference_Transform(target_size=self.IMAGE_SIZE)
|
|
122
126
|
|
|
123
127
|
def results_generation(self, logits, img_id, id_strip=None):
|
|
124
128
|
"""
|
|
@@ -148,10 +152,28 @@ class PlainResNetInference(nn.Module):
|
|
|
148
152
|
logits = self.forward(img.unsqueeze(0).to(self.device))
|
|
149
153
|
return self.results_generation(logits.cpu(), [img_id], id_strip=id_strip)[0]
|
|
150
154
|
|
|
151
|
-
def batch_image_classification(self,
|
|
155
|
+
def batch_image_classification(self, data_path=None, det_results=None, id_strip=None):
|
|
152
156
|
"""
|
|
153
157
|
Process a batch of images for classification.
|
|
154
158
|
"""
|
|
159
|
+
|
|
160
|
+
if data_path:
|
|
161
|
+
dataset = pw_data.ImageFolder(
|
|
162
|
+
data_path,
|
|
163
|
+
transform=self.transform,
|
|
164
|
+
path_head='.'
|
|
165
|
+
)
|
|
166
|
+
elif det_results:
|
|
167
|
+
dataset = pw_data.DetectionCrops(
|
|
168
|
+
det_results,
|
|
169
|
+
transform=self.transform,
|
|
170
|
+
path_head='.'
|
|
171
|
+
)
|
|
172
|
+
else:
|
|
173
|
+
raise Exception("Need data for inference.")
|
|
174
|
+
|
|
175
|
+
dataloader = DataLoader(dataset, batch_size=32, shuffle=False,
|
|
176
|
+
pin_memory=True, num_workers=4, drop_last=False)
|
|
155
177
|
total_logits = []
|
|
156
178
|
total_paths = []
|
|
157
179
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This is a Pytorch-Wildlife loader for the Deepfaune-New-England classifier.
|
|
3
|
+
The original model is available at: https://code.usgs.gov/vtcfwru/deepfaune-new-england/-/tree/main?ref_type=heads
|
|
4
|
+
Licence: CC0 1.0 Universal
|
|
5
|
+
Copyright USGS 2024
|
|
6
|
+
laurence.clarfeld@uvm.edu
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# Import libraries
|
|
10
|
+
|
|
11
|
+
from .base_classifier import TIMM_BaseClassifierInference
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"DFNE"
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
class DFNE(TIMM_BaseClassifierInference):
|
|
18
|
+
"""
|
|
19
|
+
Base detector class for dinov2 classifier. This class provides utility methods
|
|
20
|
+
for loading the model, performing single and batch image classifications, and
|
|
21
|
+
formatting results. Make sure the appropriate file for the model weights has been
|
|
22
|
+
downloaded to the "models" folder before running DFNE.
|
|
23
|
+
"""
|
|
24
|
+
BACKBONE = "vit_large_patch14_dinov2.lvd142m"
|
|
25
|
+
MODEL_NAME = "dfne_weights_v1_0.pth"
|
|
26
|
+
IMAGE_SIZE = 182
|
|
27
|
+
CLASS_NAMES = {
|
|
28
|
+
0: "American Marten",
|
|
29
|
+
1: "Bird sp.",
|
|
30
|
+
2: "Black Bear",
|
|
31
|
+
3: "Bobcat",
|
|
32
|
+
4: "Coyote",
|
|
33
|
+
5: "Domestic Cat",
|
|
34
|
+
6: "Domestic Cow",
|
|
35
|
+
7: "Domestic Dog",
|
|
36
|
+
8: "Fisher",
|
|
37
|
+
9: "Gray Fox",
|
|
38
|
+
10: "Gray Squirrel",
|
|
39
|
+
11: "Human",
|
|
40
|
+
12: "Moose",
|
|
41
|
+
13: "Mouse sp.",
|
|
42
|
+
14: "Opossum",
|
|
43
|
+
15: "Raccoon",
|
|
44
|
+
16: "Red Fox",
|
|
45
|
+
17: "Red Squirrel",
|
|
46
|
+
18: "Skunk",
|
|
47
|
+
19: "Snowshoe Hare",
|
|
48
|
+
20: "White-tailed Deer",
|
|
49
|
+
21: "Wild Boar",
|
|
50
|
+
22: "Wild Turkey",
|
|
51
|
+
23: "no-species"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
def __init__(self, weights=None, device="cpu", transform=None):
|
|
55
|
+
url = 'https://prod-is-usgs-sb-prod-publish.s3.amazonaws.com/67ae17fcd34e3f09c0e0f002/dfne_weights_v1_0.pth'
|
|
56
|
+
super(DFNE, self).__init__(weights=weights, device=device, url=url, transform=transform, weights_key='model_state_dict')
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This is a Pytorch-Wildlife loader for the Deepfaune classifier.
|
|
3
|
+
The original Deepfaune model is available at: https://www.deepfaune.cnrs.fr/en/
|
|
4
|
+
Licence: CC BY-SA 4.0
|
|
5
|
+
Copyright CNRS 2024
|
|
6
|
+
simon.chamaille@cefe.cnrs.fr; vincent.miele@univ-lyon1.fr
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# Import libraries
|
|
10
|
+
|
|
11
|
+
from torchvision.transforms.functional import InterpolationMode
|
|
12
|
+
from .base_classifier import TIMM_BaseClassifierInference
|
|
13
|
+
from ....data import transforms as pw_trans
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"DeepfauneClassifier"
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
class DeepfauneClassifier(TIMM_BaseClassifierInference):
|
|
20
|
+
"""
|
|
21
|
+
Base detector class for dinov2 classifier. This class provides utility methods
|
|
22
|
+
for loading the model, performing single and batch image classifications, and
|
|
23
|
+
formatting results. Make sure the appropriate file for the model weights has been
|
|
24
|
+
downloaded to the "models" folder before running DFNE.
|
|
25
|
+
"""
|
|
26
|
+
BACKBONE = "vit_large_patch14_dinov2.lvd142m"
|
|
27
|
+
MODEL_NAME = "deepfaune-vit_large_patch14_dinov2.lvd142m.v3.pt"
|
|
28
|
+
IMAGE_SIZE = 182
|
|
29
|
+
CLASS_NAMES={
|
|
30
|
+
'fr': ['bison', 'blaireau', 'bouquetin', 'castor', 'cerf', 'chamois', 'chat', 'chevre', 'chevreuil', 'chien', 'daim', 'ecureuil', 'elan', 'equide', 'genette', 'glouton', 'herisson', 'lagomorphe', 'loup', 'loutre', 'lynx', 'marmotte', 'micromammifere', 'mouflon', 'mouton', 'mustelide', 'oiseau', 'ours', 'ragondin', 'raton laveur', 'renard', 'renne', 'sanglier', 'vache'],
|
|
31
|
+
'en': ['bison', 'badger', 'ibex', 'beaver', 'red deer', 'chamois', 'cat', 'goat', 'roe deer', 'dog', 'fallow deer', 'squirrel', 'moose', 'equid', 'genet', 'wolverine', 'hedgehog', 'lagomorph', 'wolf', 'otter', 'lynx', 'marmot', 'micromammal', 'mouflon', 'sheep', 'mustelid', 'bird', 'bear', 'nutria', 'raccoon', 'fox', 'reindeer', 'wild boar', 'cow'],
|
|
32
|
+
'it': ['bisonte', 'tasso', 'stambecco', 'castoro', 'cervo', 'camoscio', 'gatto', 'capra', 'capriolo', 'cane', 'daino', 'scoiattolo', 'alce', 'equide', 'genetta', 'ghiottone', 'riccio', 'lagomorfo', 'lupo', 'lontra', 'lince', 'marmotta', 'micromammifero', 'muflone', 'pecora', 'mustelide', 'uccello', 'orso', 'nutria', 'procione', 'volpe', 'renna', 'cinghiale', 'mucca'],
|
|
33
|
+
'de': ['Bison', 'Dachs', 'Steinbock', 'Biber', 'Rothirsch', 'Gämse', 'Katze', 'Ziege', 'Rehwild', 'Hund', 'Damwild', 'Eichhörnchen', 'Elch', 'Equide', 'Ginsterkatze', 'Vielfraß', 'Igel', 'Lagomorpha', 'Wolf', 'Otter', 'Luchs', 'Murmeltier', 'Kleinsäuger', 'Mufflon', 'Schaf', 'Marder', 'Vogel', 'Bär', 'Nutria', 'Waschbär', 'Fuchs', 'Rentier', 'Wildschwein', 'Kuh'],
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def __init__(self, weights=None, device="cpu", transform=None, class_name_lang='en'):
|
|
38
|
+
url = 'https://pbil.univ-lyon1.fr/software/download/deepfaune/v1.3/deepfaune-vit_large_patch14_dinov2.lvd142m.v3.pt'
|
|
39
|
+
self.CLASS_NAMES = {i: c for i, c in enumerate(self.CLASS_NAMES[class_name_lang])}
|
|
40
|
+
if transform is None:
|
|
41
|
+
transform = pw_trans.Classification_Inference_Transform(target_size=self.IMAGE_SIZE,
|
|
42
|
+
interpolation=InterpolationMode.BICUBIC,
|
|
43
|
+
max_size=None,
|
|
44
|
+
antialias=None)
|
|
45
|
+
super(DeepfauneClassifier, self).__init__(weights=weights, device=device, url=url, transform=transform,
|
|
46
|
+
weights_key='state_dict', weights_prefix='base_model.')
|
|
47
|
+
|