bplusplus 0.1.0__tar.gz → 1.1.0__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.

Potentially problematic release.


This version of bplusplus might be problematic. Click here for more details.

Files changed (97) hide show
  1. bplusplus-1.1.0/PKG-INFO +179 -0
  2. bplusplus-1.1.0/README.md +157 -0
  3. {bplusplus-0.1.0 → bplusplus-1.1.0}/pyproject.toml +5 -5
  4. bplusplus-1.1.0/src/bplusplus/__init__.py +5 -0
  5. bplusplus-0.1.0/src/bplusplus/collect_images.py → bplusplus-1.1.0/src/bplusplus/collect.py +3 -3
  6. bplusplus-1.1.0/src/bplusplus/prepare.py +573 -0
  7. bplusplus-1.1.0/src/bplusplus/train_validate.py +11 -0
  8. bplusplus-1.1.0/src/bplusplus/yolov5detect/__init__.py +1 -0
  9. bplusplus-1.1.0/src/bplusplus/yolov5detect/detect.py +444 -0
  10. bplusplus-1.1.0/src/bplusplus/yolov5detect/export.py +1530 -0
  11. bplusplus-1.1.0/src/bplusplus/yolov5detect/insect.yaml +8 -0
  12. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/__init__.py +0 -0
  13. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/common.py +1109 -0
  14. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/experimental.py +130 -0
  15. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/anchors.yaml +56 -0
  16. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/yolov3-spp.yaml +52 -0
  17. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/yolov3-tiny.yaml +42 -0
  18. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/yolov3.yaml +52 -0
  19. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/yolov5-bifpn.yaml +49 -0
  20. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/yolov5-fpn.yaml +43 -0
  21. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/yolov5-p2.yaml +55 -0
  22. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/yolov5-p34.yaml +42 -0
  23. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/yolov5-p6.yaml +57 -0
  24. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/yolov5-p7.yaml +68 -0
  25. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/yolov5-panet.yaml +49 -0
  26. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/yolov5l6.yaml +61 -0
  27. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/yolov5m6.yaml +61 -0
  28. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/yolov5n6.yaml +61 -0
  29. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/yolov5s-LeakyReLU.yaml +50 -0
  30. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/yolov5s-ghost.yaml +49 -0
  31. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/yolov5s-transformer.yaml +49 -0
  32. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/yolov5s6.yaml +61 -0
  33. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/hub/yolov5x6.yaml +61 -0
  34. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/segment/yolov5l-seg.yaml +49 -0
  35. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/segment/yolov5m-seg.yaml +49 -0
  36. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/segment/yolov5n-seg.yaml +49 -0
  37. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/segment/yolov5s-seg.yaml +49 -0
  38. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/segment/yolov5x-seg.yaml +49 -0
  39. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/tf.py +797 -0
  40. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/yolo.py +495 -0
  41. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/yolov5l.yaml +49 -0
  42. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/yolov5m.yaml +49 -0
  43. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/yolov5n.yaml +49 -0
  44. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/yolov5s.yaml +49 -0
  45. bplusplus-1.1.0/src/bplusplus/yolov5detect/models/yolov5x.yaml +49 -0
  46. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/__init__.py +97 -0
  47. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/activations.py +134 -0
  48. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/augmentations.py +448 -0
  49. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/autoanchor.py +175 -0
  50. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/autobatch.py +70 -0
  51. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/aws/__init__.py +0 -0
  52. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/aws/mime.sh +26 -0
  53. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/aws/resume.py +41 -0
  54. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/aws/userdata.sh +27 -0
  55. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/callbacks.py +72 -0
  56. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/dataloaders.py +1385 -0
  57. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/docker/Dockerfile +73 -0
  58. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/docker/Dockerfile-arm64 +40 -0
  59. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/docker/Dockerfile-cpu +42 -0
  60. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/downloads.py +136 -0
  61. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/flask_rest_api/README.md +70 -0
  62. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/flask_rest_api/example_request.py +17 -0
  63. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/flask_rest_api/restapi.py +49 -0
  64. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/general.py +1294 -0
  65. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/google_app_engine/Dockerfile +25 -0
  66. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/google_app_engine/additional_requirements.txt +6 -0
  67. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/google_app_engine/app.yaml +16 -0
  68. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/loggers/__init__.py +476 -0
  69. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/loggers/clearml/README.md +222 -0
  70. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/loggers/clearml/__init__.py +0 -0
  71. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/loggers/clearml/clearml_utils.py +230 -0
  72. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/loggers/clearml/hpo.py +90 -0
  73. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/loggers/comet/README.md +250 -0
  74. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/loggers/comet/__init__.py +551 -0
  75. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/loggers/comet/comet_utils.py +151 -0
  76. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/loggers/comet/hpo.py +126 -0
  77. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/loggers/comet/optimizer_config.json +135 -0
  78. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/loggers/wandb/__init__.py +0 -0
  79. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/loggers/wandb/wandb_utils.py +210 -0
  80. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/loss.py +259 -0
  81. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/metrics.py +381 -0
  82. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/plots.py +517 -0
  83. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/segment/__init__.py +0 -0
  84. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/segment/augmentations.py +100 -0
  85. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/segment/dataloaders.py +366 -0
  86. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/segment/general.py +160 -0
  87. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/segment/loss.py +198 -0
  88. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/segment/metrics.py +225 -0
  89. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/segment/plots.py +152 -0
  90. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/torch_utils.py +482 -0
  91. bplusplus-1.1.0/src/bplusplus/yolov5detect/utils/triton.py +90 -0
  92. bplusplus-0.1.0/PKG-INFO +0 -91
  93. bplusplus-0.1.0/README.md +0 -70
  94. bplusplus-0.1.0/src/bplusplus/__init__.py +0 -3
  95. bplusplus-0.1.0/src/bplusplus/build_model.py +0 -38
  96. bplusplus-0.1.0/src/bplusplus/train_validate.py +0 -67
  97. {bplusplus-0.1.0 → bplusplus-1.1.0}/LICENSE +0 -0
@@ -0,0 +1,179 @@
1
+ Metadata-Version: 2.1
2
+ Name: bplusplus
3
+ Version: 1.1.0
4
+ Summary: A simple method to create AI models for biodiversity, with collect and prepare pipeline
5
+ License: MIT
6
+ Author: Titus Venverloo
7
+ Author-email: tvenver@mit.edu
8
+ Requires-Python: >=3.9.0,<4.0.0
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Requires-Dist: prettytable (==3.7.0)
16
+ Requires-Dist: pygbif (>=0.6.4,<0.7.0)
17
+ Requires-Dist: requests (==2.25.1)
18
+ Requires-Dist: ultralytics (==8.0.195)
19
+ Requires-Dist: validators (>=0.33.0,<0.34.0)
20
+ Description-Content-Type: text/markdown
21
+
22
+ # B++ repository
23
+
24
+ [![DOI](https://zenodo.org/badge/765250194.svg)](https://zenodo.org/badge/latestdoi/765250194)
25
+ [![PyPi version](https://img.shields.io/pypi/v/bplusplus.svg)](https://pypi.org/project/bplusplus/)
26
+ [![Python versions](https://img.shields.io/pypi/pyversions/bplusplus.svg)](https://pypi.org/project/bplusplus/)
27
+ [![License](https://img.shields.io/pypi/l/bplusplus.svg)](https://pypi.org/project/bplusplus/)
28
+ [![Downloads](https://static.pepy.tech/badge/bplusplus)](https://pepy.tech/project/bplusplus)
29
+ [![Downloads](https://static.pepy.tech/badge/bplusplus/month)](https://pepy.tech/project/bplusplus)
30
+ [![Downloads](https://static.pepy.tech/badge/bplusplus/week)](https://pepy.tech/project/bplusplus)
31
+
32
+ This repo can be used to quickly generate YOLOv8 models for biodiversity monitoring, relying on Ultralytics and a GBIF dataset.
33
+
34
+ All code is tested on macOS and Python 3.12, without GPU. GPU would obviously accelerate the below steps, Ultralytics should automatically select the available GPU if there is any.
35
+
36
+ # How does it work?
37
+
38
+ To use the bplusplus package to train your own insect detection model, we provide four functions: `collect()`, `prepare()`, `train()`, `validate()`. When training an object detection model, you need a dataset with labeled data of insect species. For this package in the `collect()` function, we use images from the GBIF database (https://doi.org/10.15468/dl.dk9czq) and run them through a pretrained *insect detection model*, defining the bounding boxes for the insects, and add the scientific name from the file path. In that way, we are able to prepare a full dataset of labeled and classified insect data for training.
39
+
40
+ ![Bplusplus overview](./bplusplus2-overview.png)
41
+
42
+ ### Install package
43
+
44
+ ```python
45
+ pip install bplusplus
46
+ ```
47
+
48
+ ### bplusplus.collect()
49
+
50
+ This function takes three arguments:
51
+ - **search_parameters: dict[str, Any]** - List of scientific names of the species you want to collect from the GBIF database
52
+ - **images_per_group: int** - Number of images per species collected for training
53
+ - **output_directory: str** - Directory to store collected images
54
+
55
+ Example run:
56
+ ```python
57
+ species_list=[ "Vanessa atalanta", "Gonepteryx rhamni", "Bombus hortorum"]
58
+ images_per_group=20
59
+ output_directory="/dataset/selected-species"
60
+
61
+ # Collect data from GBIF
62
+ bplusplus.collect(
63
+ search_parameters=species_list,
64
+ images_per_group=images_per_group,
65
+ output_directory=output_directory
66
+ )
67
+ ```
68
+
69
+ ### bplusplus.prepare()
70
+
71
+ Prepares the dataset for training by performing the following steps:
72
+ 1. Copies images from the input directory to a temporary directory.
73
+ 2. Deletes corrupted images.
74
+ 3. Downloads YOLOv5 weights for *insect detection* if not already present.
75
+ 4. Runs YOLOv5 inference to generate labels for the images.
76
+ 5. Deletes orphaned images and inferences.
77
+ 6. Updates labels based on class mapping.
78
+ 7. Splits the data into train, test, and validation sets.
79
+ 8. Counts the total number of images across all splits.
80
+ 9. Makes a YAML configuration file for YOLOv8.
81
+
82
+ This function takes three arguments:
83
+ - **input_directory: str** - The path to the input directory containing the images.
84
+ - **output_directory: str** - The path to the output directory where the prepared dataset will be saved.
85
+ - **with_background: bool = False** - Set to False if you don't want to include/download background images
86
+
87
+ ```python
88
+ # Prepare data
89
+ bplusplus.prepare(
90
+ input_directory='/dataset/selected-species',
91
+ output_directory='/dataset/prepared-data',
92
+ with_background=False
93
+ )
94
+ ```
95
+
96
+ ### bplusplus.train()
97
+
98
+ This function takes five arguments:
99
+ - **input_yaml: str** - yaml file created to train the model
100
+ - **output_directory: str**
101
+ - **epochs: int = 30** - Number of epochs to train the model
102
+ - **imgsz: int = 640** - Image size
103
+ - **batch: int = 16** - Batch size for training
104
+
105
+ ```python
106
+ # Train model
107
+ model = bplusplus.train(
108
+ input_yaml="/dataset/prepared-data/dataset.yaml", # Make sure to add the correct path
109
+ output_directory="trained-model",
110
+ epochs=30,
111
+ batch=16
112
+ )
113
+ ```
114
+
115
+ ### bplusplus.validate()
116
+
117
+ This function takes two arguments:
118
+ - **model** - The trained YOLO model
119
+ - **Path to yaml file**
120
+
121
+ ```python
122
+ metrics = bplusplus.validate(model, '/dataset/prepared-data/dataset.yaml')
123
+ print(metrics)
124
+ ```
125
+
126
+
127
+
128
+ ## Full example
129
+ ```python
130
+ import bplusplus
131
+
132
+ species_list=[ "Vanessa atalanta", "Gonepteryx rhamni", "Bombus hortorum"]
133
+ images_per_group=20
134
+ output_directory="/dataset/selected-species"
135
+
136
+ # Collect data from GBIF
137
+ bplusplus.collect(
138
+ search_parameters=species_list,
139
+ images_per_group=images_per_group,
140
+ output_directory=output_directory
141
+ )
142
+
143
+ # Prepare data
144
+ bplusplus.prepare(
145
+ input_directory='/dataset/selected-species',
146
+ output_directory='/dataset/prepared-data',
147
+ with_background=False
148
+ )
149
+
150
+ # Train model
151
+ model = bplusplus.train(
152
+ input_yaml="/dataset/prepared-data/dataset.yaml", # Make sure to add the correct path
153
+ output_directory="trained-model",
154
+ epochs=30,
155
+ batch=16
156
+ )
157
+
158
+ # Validate model
159
+ metrics = bplusplus.validate(model, '/dataset/prepared-data/dataset.yaml')
160
+ print(metrics)
161
+
162
+ ```
163
+
164
+ You have created a YOLOv8 model for insect detection.
165
+
166
+ # Earlier releases
167
+
168
+ There is also a pretrained YOLOv8 classification model, containing 2584 species, from an earlier release and paper.
169
+ The CV model as presented in the paper can be downloaded from: https://drive.google.com/file/d/1wxAIdSzx5nhTOk4izc0RIycoecSdug_Q/view?usp=sharing
170
+
171
+ To run/use the model, please consult the Ultralytics documentation.
172
+
173
+
174
+ # Citation
175
+
176
+ All information in this GitHub is available under MIT license, as long as credit is given to the authors.
177
+
178
+ **Venverloo, T., Duarte, F., B++: Towards Real-Time Monitoring of Insect Species. MIT Senseable City Laboratory, AMS Institute.**
179
+
@@ -0,0 +1,157 @@
1
+ # B++ repository
2
+
3
+ [![DOI](https://zenodo.org/badge/765250194.svg)](https://zenodo.org/badge/latestdoi/765250194)
4
+ [![PyPi version](https://img.shields.io/pypi/v/bplusplus.svg)](https://pypi.org/project/bplusplus/)
5
+ [![Python versions](https://img.shields.io/pypi/pyversions/bplusplus.svg)](https://pypi.org/project/bplusplus/)
6
+ [![License](https://img.shields.io/pypi/l/bplusplus.svg)](https://pypi.org/project/bplusplus/)
7
+ [![Downloads](https://static.pepy.tech/badge/bplusplus)](https://pepy.tech/project/bplusplus)
8
+ [![Downloads](https://static.pepy.tech/badge/bplusplus/month)](https://pepy.tech/project/bplusplus)
9
+ [![Downloads](https://static.pepy.tech/badge/bplusplus/week)](https://pepy.tech/project/bplusplus)
10
+
11
+ This repo can be used to quickly generate YOLOv8 models for biodiversity monitoring, relying on Ultralytics and a GBIF dataset.
12
+
13
+ All code is tested on macOS and Python 3.12, without GPU. GPU would obviously accelerate the below steps, Ultralytics should automatically select the available GPU if there is any.
14
+
15
+ # How does it work?
16
+
17
+ To use the bplusplus package to train your own insect detection model, we provide four functions: `collect()`, `prepare()`, `train()`, `validate()`. When training an object detection model, you need a dataset with labeled data of insect species. For this package in the `collect()` function, we use images from the GBIF database (https://doi.org/10.15468/dl.dk9czq) and run them through a pretrained *insect detection model*, defining the bounding boxes for the insects, and add the scientific name from the file path. In that way, we are able to prepare a full dataset of labeled and classified insect data for training.
18
+
19
+ ![Bplusplus overview](./bplusplus2-overview.png)
20
+
21
+ ### Install package
22
+
23
+ ```python
24
+ pip install bplusplus
25
+ ```
26
+
27
+ ### bplusplus.collect()
28
+
29
+ This function takes three arguments:
30
+ - **search_parameters: dict[str, Any]** - List of scientific names of the species you want to collect from the GBIF database
31
+ - **images_per_group: int** - Number of images per species collected for training
32
+ - **output_directory: str** - Directory to store collected images
33
+
34
+ Example run:
35
+ ```python
36
+ species_list=[ "Vanessa atalanta", "Gonepteryx rhamni", "Bombus hortorum"]
37
+ images_per_group=20
38
+ output_directory="/dataset/selected-species"
39
+
40
+ # Collect data from GBIF
41
+ bplusplus.collect(
42
+ search_parameters=species_list,
43
+ images_per_group=images_per_group,
44
+ output_directory=output_directory
45
+ )
46
+ ```
47
+
48
+ ### bplusplus.prepare()
49
+
50
+ Prepares the dataset for training by performing the following steps:
51
+ 1. Copies images from the input directory to a temporary directory.
52
+ 2. Deletes corrupted images.
53
+ 3. Downloads YOLOv5 weights for *insect detection* if not already present.
54
+ 4. Runs YOLOv5 inference to generate labels for the images.
55
+ 5. Deletes orphaned images and inferences.
56
+ 6. Updates labels based on class mapping.
57
+ 7. Splits the data into train, test, and validation sets.
58
+ 8. Counts the total number of images across all splits.
59
+ 9. Makes a YAML configuration file for YOLOv8.
60
+
61
+ This function takes three arguments:
62
+ - **input_directory: str** - The path to the input directory containing the images.
63
+ - **output_directory: str** - The path to the output directory where the prepared dataset will be saved.
64
+ - **with_background: bool = False** - Set to False if you don't want to include/download background images
65
+
66
+ ```python
67
+ # Prepare data
68
+ bplusplus.prepare(
69
+ input_directory='/dataset/selected-species',
70
+ output_directory='/dataset/prepared-data',
71
+ with_background=False
72
+ )
73
+ ```
74
+
75
+ ### bplusplus.train()
76
+
77
+ This function takes five arguments:
78
+ - **input_yaml: str** - yaml file created to train the model
79
+ - **output_directory: str**
80
+ - **epochs: int = 30** - Number of epochs to train the model
81
+ - **imgsz: int = 640** - Image size
82
+ - **batch: int = 16** - Batch size for training
83
+
84
+ ```python
85
+ # Train model
86
+ model = bplusplus.train(
87
+ input_yaml="/dataset/prepared-data/dataset.yaml", # Make sure to add the correct path
88
+ output_directory="trained-model",
89
+ epochs=30,
90
+ batch=16
91
+ )
92
+ ```
93
+
94
+ ### bplusplus.validate()
95
+
96
+ This function takes two arguments:
97
+ - **model** - The trained YOLO model
98
+ - **Path to yaml file**
99
+
100
+ ```python
101
+ metrics = bplusplus.validate(model, '/dataset/prepared-data/dataset.yaml')
102
+ print(metrics)
103
+ ```
104
+
105
+
106
+
107
+ ## Full example
108
+ ```python
109
+ import bplusplus
110
+
111
+ species_list=[ "Vanessa atalanta", "Gonepteryx rhamni", "Bombus hortorum"]
112
+ images_per_group=20
113
+ output_directory="/dataset/selected-species"
114
+
115
+ # Collect data from GBIF
116
+ bplusplus.collect(
117
+ search_parameters=species_list,
118
+ images_per_group=images_per_group,
119
+ output_directory=output_directory
120
+ )
121
+
122
+ # Prepare data
123
+ bplusplus.prepare(
124
+ input_directory='/dataset/selected-species',
125
+ output_directory='/dataset/prepared-data',
126
+ with_background=False
127
+ )
128
+
129
+ # Train model
130
+ model = bplusplus.train(
131
+ input_yaml="/dataset/prepared-data/dataset.yaml", # Make sure to add the correct path
132
+ output_directory="trained-model",
133
+ epochs=30,
134
+ batch=16
135
+ )
136
+
137
+ # Validate model
138
+ metrics = bplusplus.validate(model, '/dataset/prepared-data/dataset.yaml')
139
+ print(metrics)
140
+
141
+ ```
142
+
143
+ You have created a YOLOv8 model for insect detection.
144
+
145
+ # Earlier releases
146
+
147
+ There is also a pretrained YOLOv8 classification model, containing 2584 species, from an earlier release and paper.
148
+ The CV model as presented in the paper can be downloaded from: https://drive.google.com/file/d/1wxAIdSzx5nhTOk4izc0RIycoecSdug_Q/view?usp=sharing
149
+
150
+ To run/use the model, please consult the Ultralytics documentation.
151
+
152
+
153
+ # Citation
154
+
155
+ All information in this GitHub is available under MIT license, as long as credit is given to the authors.
156
+
157
+ **Venverloo, T., Duarte, F., B++: Towards Real-Time Monitoring of Insect Species. MIT Senseable City Laboratory, AMS Institute.**
@@ -1,8 +1,8 @@
1
1
  [tool.poetry]
2
2
  name = "bplusplus"
3
- version = "0.1.0"
4
- description = "A simple method to create AI models for biodiversity"
5
- authors = ["Titus Venverloo <tvenver@mit.edu>", "Deniz Aydemir <deniz@aydemir.us>"]
3
+ version = "1.1.0"
4
+ description = "A simple method to create AI models for biodiversity, with collect and prepare pipeline"
5
+ authors = ["Titus Venverloo <tvenver@mit.edu>", "Deniz Aydemir <deniz@aydemir.us>", "Orlando Closs <orlando.closs@wur.nl>", "Ase Hatveit <aase@mit.edu>"]
6
6
  license = "MIT"
7
7
  readme = "README.md"
8
8
 
@@ -12,12 +12,12 @@ requests = "2.25.1"
12
12
  ultralytics = "8.0.195"
13
13
  pygbif = "^0.6.4"
14
14
  validators = "^0.33.0"
15
-
15
+ prettytable = "3.7.0"
16
16
 
17
17
  [tool.poetry.group.dev.dependencies]
18
18
  jupyter = "^1.0.0"
19
19
  ipykernel = "^6.29.5"
20
20
 
21
21
  [build-system]
22
- requires = ["poetry-core"]
22
+ requires = ["poetry-core>=1.0.0"]
23
23
  build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,5 @@
1
+ from .collect import Group, collect
2
+ from .train_validate import train, validate
3
+ from .prepare import prepare
4
+ from .yolov5detect.detect import run
5
+
@@ -13,7 +13,7 @@ class Group(str, Enum):
13
13
  scientificName="scientificName"
14
14
 
15
15
  #TODO add back support for fetching from dataset (or csvs)
16
- def collect_images(group_by_key: Group, search_parameters: dict[str, Any], images_per_group: int, output_directory: str):
16
+ def collect(group_by_key: Group, search_parameters: dict[str, Any], images_per_group: int, output_directory: str):
17
17
 
18
18
  groups: list[str] = search_parameters[group_by_key.value]
19
19
 
@@ -26,12 +26,12 @@ def collect_images(group_by_key: Group, search_parameters: dict[str, Any], image
26
26
 
27
27
  print("Beginning to collect images from GBIF...")
28
28
  for group in groups:
29
- print(f"Collecting images for {group}...")
29
+ # print(f"Collecting images for {group}...")
30
30
  occurrences_json = _fetch_occurrences(group_key=group_by_key, group_value=group, parameters=search_parameters, totalLimit=10000)
31
31
  optional_occurrences = map(lambda x: __parse_occurrence(x), occurrences_json)
32
32
  occurrences = list(filter(None, optional_occurrences))
33
33
 
34
- print(f"{group} : {len(occurrences)} parseable occurrences fetched, will sample for {images_per_group}")
34
+ # print(f"{group} : {len(occurrences)} parseable occurrences fetched, will sample for {images_per_group}")
35
35
 
36
36
  random.seed(42) # for reproducibility
37
37
  sampled_occurrences = random.sample(occurrences, min(images_per_group, len(occurrences)))