bplusplus 0.1.1__py3-none-any.whl → 1.1.0__py3-none-any.whl

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 (95) hide show
  1. bplusplus/__init__.py +5 -3
  2. bplusplus/{collect_images.py → collect.py} +3 -3
  3. bplusplus/prepare.py +573 -0
  4. bplusplus/train_validate.py +8 -64
  5. bplusplus/yolov5detect/__init__.py +1 -0
  6. bplusplus/yolov5detect/detect.py +444 -0
  7. bplusplus/yolov5detect/export.py +1530 -0
  8. bplusplus/yolov5detect/insect.yaml +8 -0
  9. bplusplus/yolov5detect/models/__init__.py +0 -0
  10. bplusplus/yolov5detect/models/common.py +1109 -0
  11. bplusplus/yolov5detect/models/experimental.py +130 -0
  12. bplusplus/yolov5detect/models/hub/anchors.yaml +56 -0
  13. bplusplus/yolov5detect/models/hub/yolov3-spp.yaml +52 -0
  14. bplusplus/yolov5detect/models/hub/yolov3-tiny.yaml +42 -0
  15. bplusplus/yolov5detect/models/hub/yolov3.yaml +52 -0
  16. bplusplus/yolov5detect/models/hub/yolov5-bifpn.yaml +49 -0
  17. bplusplus/yolov5detect/models/hub/yolov5-fpn.yaml +43 -0
  18. bplusplus/yolov5detect/models/hub/yolov5-p2.yaml +55 -0
  19. bplusplus/yolov5detect/models/hub/yolov5-p34.yaml +42 -0
  20. bplusplus/yolov5detect/models/hub/yolov5-p6.yaml +57 -0
  21. bplusplus/yolov5detect/models/hub/yolov5-p7.yaml +68 -0
  22. bplusplus/yolov5detect/models/hub/yolov5-panet.yaml +49 -0
  23. bplusplus/yolov5detect/models/hub/yolov5l6.yaml +61 -0
  24. bplusplus/yolov5detect/models/hub/yolov5m6.yaml +61 -0
  25. bplusplus/yolov5detect/models/hub/yolov5n6.yaml +61 -0
  26. bplusplus/yolov5detect/models/hub/yolov5s-LeakyReLU.yaml +50 -0
  27. bplusplus/yolov5detect/models/hub/yolov5s-ghost.yaml +49 -0
  28. bplusplus/yolov5detect/models/hub/yolov5s-transformer.yaml +49 -0
  29. bplusplus/yolov5detect/models/hub/yolov5s6.yaml +61 -0
  30. bplusplus/yolov5detect/models/hub/yolov5x6.yaml +61 -0
  31. bplusplus/yolov5detect/models/segment/yolov5l-seg.yaml +49 -0
  32. bplusplus/yolov5detect/models/segment/yolov5m-seg.yaml +49 -0
  33. bplusplus/yolov5detect/models/segment/yolov5n-seg.yaml +49 -0
  34. bplusplus/yolov5detect/models/segment/yolov5s-seg.yaml +49 -0
  35. bplusplus/yolov5detect/models/segment/yolov5x-seg.yaml +49 -0
  36. bplusplus/yolov5detect/models/tf.py +797 -0
  37. bplusplus/yolov5detect/models/yolo.py +495 -0
  38. bplusplus/yolov5detect/models/yolov5l.yaml +49 -0
  39. bplusplus/yolov5detect/models/yolov5m.yaml +49 -0
  40. bplusplus/yolov5detect/models/yolov5n.yaml +49 -0
  41. bplusplus/yolov5detect/models/yolov5s.yaml +49 -0
  42. bplusplus/yolov5detect/models/yolov5x.yaml +49 -0
  43. bplusplus/yolov5detect/utils/__init__.py +97 -0
  44. bplusplus/yolov5detect/utils/activations.py +134 -0
  45. bplusplus/yolov5detect/utils/augmentations.py +448 -0
  46. bplusplus/yolov5detect/utils/autoanchor.py +175 -0
  47. bplusplus/yolov5detect/utils/autobatch.py +70 -0
  48. bplusplus/yolov5detect/utils/aws/__init__.py +0 -0
  49. bplusplus/yolov5detect/utils/aws/mime.sh +26 -0
  50. bplusplus/yolov5detect/utils/aws/resume.py +41 -0
  51. bplusplus/yolov5detect/utils/aws/userdata.sh +27 -0
  52. bplusplus/yolov5detect/utils/callbacks.py +72 -0
  53. bplusplus/yolov5detect/utils/dataloaders.py +1385 -0
  54. bplusplus/yolov5detect/utils/docker/Dockerfile +73 -0
  55. bplusplus/yolov5detect/utils/docker/Dockerfile-arm64 +40 -0
  56. bplusplus/yolov5detect/utils/docker/Dockerfile-cpu +42 -0
  57. bplusplus/yolov5detect/utils/downloads.py +136 -0
  58. bplusplus/yolov5detect/utils/flask_rest_api/README.md +70 -0
  59. bplusplus/yolov5detect/utils/flask_rest_api/example_request.py +17 -0
  60. bplusplus/yolov5detect/utils/flask_rest_api/restapi.py +49 -0
  61. bplusplus/yolov5detect/utils/general.py +1294 -0
  62. bplusplus/yolov5detect/utils/google_app_engine/Dockerfile +25 -0
  63. bplusplus/yolov5detect/utils/google_app_engine/additional_requirements.txt +6 -0
  64. bplusplus/yolov5detect/utils/google_app_engine/app.yaml +16 -0
  65. bplusplus/yolov5detect/utils/loggers/__init__.py +476 -0
  66. bplusplus/yolov5detect/utils/loggers/clearml/README.md +222 -0
  67. bplusplus/yolov5detect/utils/loggers/clearml/__init__.py +0 -0
  68. bplusplus/yolov5detect/utils/loggers/clearml/clearml_utils.py +230 -0
  69. bplusplus/yolov5detect/utils/loggers/clearml/hpo.py +90 -0
  70. bplusplus/yolov5detect/utils/loggers/comet/README.md +250 -0
  71. bplusplus/yolov5detect/utils/loggers/comet/__init__.py +551 -0
  72. bplusplus/yolov5detect/utils/loggers/comet/comet_utils.py +151 -0
  73. bplusplus/yolov5detect/utils/loggers/comet/hpo.py +126 -0
  74. bplusplus/yolov5detect/utils/loggers/comet/optimizer_config.json +135 -0
  75. bplusplus/yolov5detect/utils/loggers/wandb/__init__.py +0 -0
  76. bplusplus/yolov5detect/utils/loggers/wandb/wandb_utils.py +210 -0
  77. bplusplus/yolov5detect/utils/loss.py +259 -0
  78. bplusplus/yolov5detect/utils/metrics.py +381 -0
  79. bplusplus/yolov5detect/utils/plots.py +517 -0
  80. bplusplus/yolov5detect/utils/segment/__init__.py +0 -0
  81. bplusplus/yolov5detect/utils/segment/augmentations.py +100 -0
  82. bplusplus/yolov5detect/utils/segment/dataloaders.py +366 -0
  83. bplusplus/yolov5detect/utils/segment/general.py +160 -0
  84. bplusplus/yolov5detect/utils/segment/loss.py +198 -0
  85. bplusplus/yolov5detect/utils/segment/metrics.py +225 -0
  86. bplusplus/yolov5detect/utils/segment/plots.py +152 -0
  87. bplusplus/yolov5detect/utils/torch_utils.py +482 -0
  88. bplusplus/yolov5detect/utils/triton.py +90 -0
  89. bplusplus-1.1.0.dist-info/METADATA +179 -0
  90. bplusplus-1.1.0.dist-info/RECORD +92 -0
  91. bplusplus/build_model.py +0 -38
  92. bplusplus-0.1.1.dist-info/METADATA +0 -97
  93. bplusplus-0.1.1.dist-info/RECORD +0 -8
  94. {bplusplus-0.1.1.dist-info → bplusplus-1.1.0.dist-info}/LICENSE +0 -0
  95. {bplusplus-0.1.1.dist-info → bplusplus-1.1.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,250 @@
1
+ <img src="https://cdn.comet.ml/img/notebook_logo.png">
2
+
3
+ # YOLOv5 with Comet
4
+
5
+ This guide will cover how to use YOLOv5 with [Comet](https://bit.ly/yolov5-readme-comet2)
6
+
7
+ # About Comet
8
+
9
+ Comet builds tools that help data scientists, engineers, and team leaders accelerate and optimize machine learning and deep learning models.
10
+
11
+ Track and visualize model metrics in real time, save your hyperparameters, datasets, and model checkpoints, and visualize your model predictions with [Comet Custom Panels](https://www.comet.com/docs/v2/guides/comet-dashboard/code-panels/about-panels/?utm_source=yolov5&utm_medium=partner&utm_campaign=partner_yolov5_2022&utm_content=github)! Comet makes sure you never lose track of your work and makes it easy to share results and collaborate across teams of all sizes!
12
+
13
+ # Getting Started
14
+
15
+ ## Install Comet
16
+
17
+ ```shell
18
+ pip install comet_ml
19
+ ```
20
+
21
+ ## Configure Comet Credentials
22
+
23
+ There are two ways to configure Comet with YOLOv5.
24
+
25
+ You can either set your credentials through environment variables
26
+
27
+ **Environment Variables**
28
+
29
+ ```shell
30
+ export COMET_API_KEY=<Your Comet API Key>
31
+ export COMET_PROJECT_NAME=<Your Comet Project Name> # This will default to 'yolov5'
32
+ ```
33
+
34
+ Or create a `.comet.config` file in your working directory and set your credentials there.
35
+
36
+ **Comet Configuration File**
37
+
38
+ ```
39
+ [comet]
40
+ api_key=<Your Comet API Key>
41
+ project_name=<Your Comet Project Name> # This will default to 'yolov5'
42
+ ```
43
+
44
+ ## Run the Training Script
45
+
46
+ ```shell
47
+ # Train YOLOv5s on COCO128 for 5 epochs
48
+ python train.py --img 640 --batch 16 --epochs 5 --data coco128.yaml --weights yolov5s.pt
49
+ ```
50
+
51
+ That's it! Comet will automatically log your hyperparameters, command line arguments, training and validation metrics. You can visualize and analyze your runs in the Comet UI
52
+
53
+ <img width="1920" alt="yolo-ui" src="https://user-images.githubusercontent.com/26833433/202851203-164e94e1-2238-46dd-91f8-de020e9d6b41.png">
54
+
55
+ # Try out an Example!
56
+
57
+ Check out an example of a [completed run here](https://www.comet.com/examples/comet-example-yolov5/a0e29e0e9b984e4a822db2a62d0cb357?experiment-tab=chart&showOutliers=true&smoothing=0&transformY=smoothing&xAxis=step&utm_source=yolov5&utm_medium=partner&utm_campaign=partner_yolov5_2022&utm_content=github)
58
+
59
+ Or better yet, try it out yourself in this Colab Notebook
60
+
61
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/comet-ml/comet-examples/blob/master/integrations/model-training/yolov5/notebooks/Comet_and_YOLOv5.ipynb)
62
+
63
+ # Log automatically
64
+
65
+ By default, Comet will log the following items
66
+
67
+ ## Metrics
68
+
69
+ - Box Loss, Object Loss, Classification Loss for the training and validation data
70
+ - mAP_0.5, mAP_0.5:0.95 metrics for the validation data.
71
+ - Precision and Recall for the validation data
72
+
73
+ ## Parameters
74
+
75
+ - Model Hyperparameters
76
+ - All parameters passed through the command line options
77
+
78
+ ## Visualizations
79
+
80
+ - Confusion Matrix of the model predictions on the validation data
81
+ - Plots for the PR and F1 curves across all classes
82
+ - Correlogram of the Class Labels
83
+
84
+ # Configure Comet Logging
85
+
86
+ Comet can be configured to log additional data either through command line flags passed to the training script or through environment variables.
87
+
88
+ ```shell
89
+ export COMET_MODE=online # Set whether to run Comet in 'online' or 'offline' mode. Defaults to online
90
+ export COMET_MODEL_NAME=<your model name> #Set the name for the saved model. Defaults to yolov5
91
+ export COMET_LOG_CONFUSION_MATRIX=false # Set to disable logging a Comet Confusion Matrix. Defaults to true
92
+ export COMET_MAX_IMAGE_UPLOADS=<number of allowed images to upload to Comet> # Controls how many total image predictions to log to Comet. Defaults to 100.
93
+ export COMET_LOG_PER_CLASS_METRICS=true # Set to log evaluation metrics for each detected class at the end of training. Defaults to false
94
+ export COMET_DEFAULT_CHECKPOINT_FILENAME=<your checkpoint filename> # Set this if you would like to resume training from a different checkpoint. Defaults to 'last.pt'
95
+ export COMET_LOG_BATCH_LEVEL_METRICS=true # Set this if you would like to log training metrics at the batch level. Defaults to false.
96
+ export COMET_LOG_PREDICTIONS=true # Set this to false to disable logging model predictions
97
+ ```
98
+
99
+ ## Logging Checkpoints with Comet
100
+
101
+ Logging Models to Comet is disabled by default. To enable it, pass the `save-period` argument to the training script. This will save the logged checkpoints to Comet based on the interval value provided by `save-period`
102
+
103
+ ```shell
104
+ python train.py \
105
+ --img 640 \
106
+ --batch 16 \
107
+ --epochs 5 \
108
+ --data coco128.yaml \
109
+ --weights yolov5s.pt \
110
+ --save-period 1
111
+ ```
112
+
113
+ ## Logging Model Predictions
114
+
115
+ By default, model predictions (images, ground truth labels and bounding boxes) will be logged to Comet.
116
+
117
+ You can control the frequency of logged predictions and the associated images by passing the `bbox_interval` command line argument. Predictions can be visualized using Comet's Object Detection Custom Panel. This frequency corresponds to every Nth batch of data per epoch. In the example below, we are logging every 2nd batch of data for each epoch.
118
+
119
+ **Note:** The YOLOv5 validation dataloader will default to a batch size of 32, so you will have to set the logging frequency accordingly.
120
+
121
+ Here is an [example project using the Panel](https://www.comet.com/examples/comet-example-yolov5?shareable=YcwMiJaZSXfcEXpGOHDD12vA1&utm_source=yolov5&utm_medium=partner&utm_campaign=partner_yolov5_2022&utm_content=github)
122
+
123
+ ```shell
124
+ python train.py \
125
+ --img 640 \
126
+ --batch 16 \
127
+ --epochs 5 \
128
+ --data coco128.yaml \
129
+ --weights yolov5s.pt \
130
+ --bbox_interval 2
131
+ ```
132
+
133
+ ### Controlling the number of Prediction Images logged to Comet
134
+
135
+ When logging predictions from YOLOv5, Comet will log the images associated with each set of predictions. By default a maximum of 100 validation images are logged. You can increase or decrease this number using the `COMET_MAX_IMAGE_UPLOADS` environment variable.
136
+
137
+ ```shell
138
+ env COMET_MAX_IMAGE_UPLOADS=200 python train.py \
139
+ --img 640 \
140
+ --batch 16 \
141
+ --epochs 5 \
142
+ --data coco128.yaml \
143
+ --weights yolov5s.pt \
144
+ --bbox_interval 1
145
+ ```
146
+
147
+ ### Logging Class Level Metrics
148
+
149
+ Use the `COMET_LOG_PER_CLASS_METRICS` environment variable to log mAP, precision, recall, f1 for each class.
150
+
151
+ ```shell
152
+ env COMET_LOG_PER_CLASS_METRICS=true python train.py \
153
+ --img 640 \
154
+ --batch 16 \
155
+ --epochs 5 \
156
+ --data coco128.yaml \
157
+ --weights yolov5s.pt
158
+ ```
159
+
160
+ ## Uploading a Dataset to Comet Artifacts
161
+
162
+ If you would like to store your data using [Comet Artifacts](https://www.comet.com/docs/v2/guides/data-management/using-artifacts/#learn-more?utm_source=yolov5&utm_medium=partner&utm_campaign=partner_yolov5_2022&utm_content=github), you can do so using the `upload_dataset` flag.
163
+
164
+ The dataset be organized in the way described in the [YOLOv5 documentation](https://docs.ultralytics.com/yolov5/tutorials/train_custom_data/). The dataset config `yaml` file must follow the same format as that of the `coco128.yaml` file.
165
+
166
+ ```shell
167
+ python train.py \
168
+ --img 640 \
169
+ --batch 16 \
170
+ --epochs 5 \
171
+ --data coco128.yaml \
172
+ --weights yolov5s.pt \
173
+ --upload_dataset
174
+ ```
175
+
176
+ You can find the uploaded dataset in the Artifacts tab in your Comet Workspace <img width="1073" alt="artifact-1" src="https://user-images.githubusercontent.com/7529846/186929193-162718bf-ec7b-4eb9-8c3b-86b3763ef8ea.png">
177
+
178
+ You can preview the data directly in the Comet UI. <img width="1082" alt="artifact-2" src="https://user-images.githubusercontent.com/7529846/186929215-432c36a9-c109-4eb0-944b-84c2786590d6.png">
179
+
180
+ Artifacts are versioned and also support adding metadata about the dataset. Comet will automatically log the metadata from your dataset `yaml` file <img width="963" alt="artifact-3" src="https://user-images.githubusercontent.com/7529846/186929256-9d44d6eb-1a19-42de-889a-bcbca3018f2e.png">
181
+
182
+ ### Using a saved Artifact
183
+
184
+ If you would like to use a dataset from Comet Artifacts, set the `path` variable in your dataset `yaml` file to point to the following Artifact resource URL.
185
+
186
+ ```
187
+ # contents of artifact.yaml file
188
+ path: "comet://<workspace name>/<artifact name>:<artifact version or alias>"
189
+ ```
190
+
191
+ Then pass this file to your training script in the following way
192
+
193
+ ```shell
194
+ python train.py \
195
+ --img 640 \
196
+ --batch 16 \
197
+ --epochs 5 \
198
+ --data artifact.yaml \
199
+ --weights yolov5s.pt
200
+ ```
201
+
202
+ Artifacts also allow you to track the lineage of data as it flows through your Experimentation workflow. Here you can see a graph that shows you all the experiments that have used your uploaded dataset. <img width="1391" alt="artifact-4" src="https://user-images.githubusercontent.com/7529846/186929264-4c4014fa-fe51-4f3c-a5c5-f6d24649b1b4.png">
203
+
204
+ ## Resuming a Training Run
205
+
206
+ If your training run is interrupted for any reason, e.g. disrupted internet connection, you can resume the run using the `resume` flag and the Comet Run Path.
207
+
208
+ The Run Path has the following format `comet://<your workspace name>/<your project name>/<experiment id>`.
209
+
210
+ This will restore the run to its state before the interruption, which includes restoring the model from a checkpoint, restoring all hyperparameters and training arguments and downloading Comet dataset Artifacts if they were used in the original run. The resumed run will continue logging to the existing Experiment in the Comet UI
211
+
212
+ ```shell
213
+ python train.py \
214
+ --resume "comet://<your run path>"
215
+ ```
216
+
217
+ ## Hyperparameter Search with the Comet Optimizer
218
+
219
+ YOLOv5 is also integrated with Comet's Optimizer, making is simple to visualize hyperparameter sweeps in the Comet UI.
220
+
221
+ ### Configuring an Optimizer Sweep
222
+
223
+ To configure the Comet Optimizer, you will have to create a JSON file with the information about the sweep. An example file has been provided in `utils/loggers/comet/optimizer_config.json`
224
+
225
+ ```shell
226
+ python utils/loggers/comet/hpo.py \
227
+ --comet_optimizer_config "utils/loggers/comet/optimizer_config.json"
228
+ ```
229
+
230
+ The `hpo.py` script accepts the same arguments as `train.py`. If you wish to pass additional arguments to your sweep simply add them after the script.
231
+
232
+ ```shell
233
+ python utils/loggers/comet/hpo.py \
234
+ --comet_optimizer_config "utils/loggers/comet/optimizer_config.json" \
235
+ --save-period 1 \
236
+ --bbox_interval 1
237
+ ```
238
+
239
+ ### Running a Sweep in Parallel
240
+
241
+ ```shell
242
+ comet optimizer -j <set number of workers> utils/loggers/comet/hpo.py \
243
+ utils/loggers/comet/optimizer_config.json"
244
+ ```
245
+
246
+ ### Visualizing Results
247
+
248
+ Comet provides a number of ways to visualize the results of your sweep. Take a look at a [project with a completed sweep here](https://www.comet.com/examples/comet-example-yolov5/view/PrlArHGuuhDTKC1UuBmTtOSXD/panels?utm_source=yolov5&utm_medium=partner&utm_campaign=partner_yolov5_2022&utm_content=github)
249
+
250
+ <img width="1626" alt="hyperparameter-yolo" src="https://user-images.githubusercontent.com/7529846/186914869-7dc1de14-583f-4323-967b-c9a66a29e495.png">