faster-coco-eval 1.6.8__tar.gz → 1.7.1__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.
Files changed (62) hide show
  1. {faster_coco_eval-1.6.8/faster_coco_eval.egg-info → faster_coco_eval-1.7.1}/PKG-INFO +2 -2
  2. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/README.md +1 -1
  3. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/csrc/faster_eval_api/coco_eval/cocoeval.cpp +118 -70
  4. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/csrc/faster_eval_api/coco_eval/cocoeval.h +21 -45
  5. faster_coco_eval-1.7.1/csrc/faster_eval_api/coco_eval/dataset.cpp +309 -0
  6. faster_coco_eval-1.7.1/csrc/faster_eval_api/coco_eval/dataset.h +95 -0
  7. faster_coco_eval-1.7.1/csrc/faster_eval_api/coco_eval/types.h +40 -0
  8. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/csrc/faster_eval_api/faster_eval_api.cpp +23 -16
  9. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/csrc/mask_api/mask_api.cpp +3 -3
  10. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/csrc/mask_api/src/mask.cpp +261 -147
  11. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/csrc/mask_api/src/mask.h +55 -55
  12. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/csrc/mask_api/src/rle.cpp +78 -35
  13. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval/core/coco.py +5 -5
  14. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval/core/cocoeval.py +61 -28
  15. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval/core/faster_eval_api.py +20 -21
  16. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval/utils/pytorch/coco_eval.py +27 -4
  17. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval/version.py +1 -1
  18. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1/faster_coco_eval.egg-info}/PKG-INFO +2 -2
  19. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval.egg-info/SOURCES.txt +4 -0
  20. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/setup.py +1 -0
  21. faster_coco_eval-1.7.1/tests/test_dataset.py +253 -0
  22. faster_coco_eval-1.7.1/tests/test_extra_utils.py +161 -0
  23. faster_coco_eval-1.7.1/tests/test_ranges.py +109 -0
  24. faster_coco_eval-1.7.1/tests/test_simple_extra.py +167 -0
  25. faster_coco_eval-1.6.8/csrc/faster_eval_api/coco_eval/dataset.cpp +0 -246
  26. faster_coco_eval-1.6.8/csrc/faster_eval_api/coco_eval/dataset.h +0 -82
  27. faster_coco_eval-1.6.8/tests/test_dataset.py +0 -66
  28. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/LICENSE +0 -0
  29. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/MANIFEST.in +0 -0
  30. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval/__init__.py +0 -0
  31. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval/core/__init__.py +0 -0
  32. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval/core/mask.py +0 -0
  33. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval/extra/__init__.py +0 -0
  34. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval/extra/curves.py +0 -0
  35. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval/extra/display.py +0 -0
  36. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval/extra/draw.py +0 -0
  37. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval/extra/extra.py +0 -0
  38. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval/extra/utils.py +0 -0
  39. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval/utils/__init__.py +0 -0
  40. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval/utils/pytorch/__init__.py +0 -0
  41. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval/utils/pytorch/coco_dataset.py +0 -0
  42. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval.egg-info/dependency_links.txt +0 -0
  43. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval.egg-info/requires.txt +0 -0
  44. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/faster_coco_eval.egg-info/top_level.txt +0 -0
  45. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/pyproject.toml +0 -0
  46. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/requirements/docs.txt +0 -0
  47. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/requirements/extra.txt +0 -0
  48. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/requirements/runtime.txt +0 -0
  49. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/requirements/tests.txt +0 -0
  50. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/setup.cfg +0 -0
  51. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/tests/test_basic.py +0 -0
  52. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/tests/test_boundary.py +0 -0
  53. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/tests/test_coco_metric.py +0 -0
  54. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/tests/test_cocoapi_fake_data.py +0 -0
  55. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/tests/test_crowdpose.py +0 -0
  56. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/tests/test_extra_draw.py +0 -0
  57. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/tests/test_init_pycocotools.py +0 -0
  58. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/tests/test_keypoints.py +0 -0
  59. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/tests/test_lvis_metric.py +0 -0
  60. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/tests/test_mask_api.py +1 -1
  61. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/tests/test_torchmetrics.py +0 -0
  62. {faster_coco_eval-1.6.8 → faster_coco_eval-1.7.1}/tests/test_world_evalutor.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: faster-coco-eval
3
- Version: 1.6.8
3
+ Version: 1.7.1
4
4
  Summary: Faster interpretation of the original COCOEval
5
5
  Home-page: https://github.com/MiXaiLL76/faster_coco_eval
6
6
  Author: MiXaiLL76
@@ -145,7 +145,7 @@ Visualization of testing **colab_example.ipynb** available in directory [example
145
145
  | bbox | 5.812 | 22.72 | 3.909 |
146
146
  | segm | 7.413 | 24.434 | 3.296 |
147
147
 
148
- ## Feautures
148
+ ## Features
149
149
 
150
150
  This library provides not only validation functions, but also error visualization functions. Including visualization of errors in the image.
151
151
  You can study in more detail in the [examples](https://mixaill76.github.io/faster_coco_eval/examples.html) and [Wiki](https://github.com/MiXaiLL76/faster_coco_eval/wiki).
@@ -98,7 +98,7 @@ Visualization of testing **colab_example.ipynb** available in directory [example
98
98
  | bbox | 5.812 | 22.72 | 3.909 |
99
99
  | segm | 7.413 | 24.434 | 3.296 |
100
100
 
101
- ## Feautures
101
+ ## Features
102
102
 
103
103
  This library provides not only validation functions, but also error visualization functions. Including visualization of errors in the image.
104
104
  You can study in more detail in the [examples](https://mixaill76.github.io/faster_coco_eval/examples.html) and [Wiki](https://github.com/MiXaiLL76/faster_coco_eval/wiki).
@@ -14,7 +14,7 @@ namespace coco_eval {
14
14
 
15
15
  namespace COCOeval {
16
16
  template <typename T>
17
- int64_t v_index(const std::vector<T> &v, const T &key) {
17
+ int64_t v_index(const std::vector<T>& v, const T& key) {
18
18
  auto itr = std::find(v.begin(), v.end(), key);
19
19
 
20
20
  if (itr != v.cend()) {
@@ -29,8 +29,8 @@ int64_t v_index(const std::vector<T> &v, const T &key) {
29
29
  // detection_instances[detection_sorted_indices[t+1]]. Use stable_sort to match
30
30
  // original COCO API
31
31
  void SortInstancesByDetectionScore(
32
- const std::vector<InstanceAnnotation> &detection_instances,
33
- std::vector<uint64_t> *detection_sorted_indices) {
32
+ const std::vector<InstanceAnnotation>& detection_instances,
33
+ std::vector<uint64_t>* detection_sorted_indices) {
34
34
  detection_sorted_indices->resize(detection_instances.size());
35
35
  std::iota(detection_sorted_indices->begin(),
36
36
  detection_sorted_indices->end(), 0);
@@ -45,10 +45,10 @@ void SortInstancesByDetectionScore(
45
45
  // Partition the ground truth objects based on whether or not to ignore them
46
46
  // based on area
47
47
  void SortInstancesByIgnore(
48
- const std::array<double, 2> &area_range,
49
- const std::vector<InstanceAnnotation> &ground_truth_instances,
50
- std::vector<uint64_t> *ground_truth_sorted_indices,
51
- std::vector<bool> *ignores) {
48
+ const std::array<double, 2>& area_range,
49
+ const std::vector<InstanceAnnotation>& ground_truth_instances,
50
+ std::vector<uint64_t>* ground_truth_sorted_indices,
51
+ std::vector<bool>* ignores) {
52
52
  ignores->clear();
53
53
  ignores->reserve(ground_truth_instances.size());
54
54
  for (auto o : ground_truth_instances) {
@@ -70,14 +70,14 @@ void SortInstancesByIgnore(
70
70
  // For each IOU threshold, greedily match each detected instance to a ground
71
71
  // truth instance (if possible) and store the results
72
72
  void MatchDetectionsToGroundTruth(
73
- const std::vector<InstanceAnnotation> &detection_instances,
74
- const std::vector<uint64_t> &detection_sorted_indices,
75
- const std::vector<InstanceAnnotation> &ground_truth_instances,
76
- const std::vector<uint64_t> &ground_truth_sorted_indices,
77
- const std::vector<bool> &ignores,
78
- const std::vector<std::vector<double>> &ious,
79
- const std::vector<double> &iou_thresholds,
80
- const std::array<double, 2> &area_range, ImageEvaluation *results) {
73
+ const std::vector<InstanceAnnotation>& detection_instances,
74
+ const std::vector<uint64_t>& detection_sorted_indices,
75
+ const std::vector<InstanceAnnotation>& ground_truth_instances,
76
+ const std::vector<uint64_t>& ground_truth_sorted_indices,
77
+ const std::vector<bool>& ignores,
78
+ const std::vector<std::vector<double>>& ious,
79
+ const std::vector<double>& iou_thresholds,
80
+ const std::array<double, 2>& area_range, ImageEvaluation* results) {
81
81
  // Initialize memory to store return data matches and ignore
82
82
  const int num_iou_thresholds = (const int)iou_thresholds.size();
83
83
  const int num_ground_truth =
@@ -85,14 +85,14 @@ void MatchDetectionsToGroundTruth(
85
85
  const int num_detections = (const int)detection_sorted_indices.size();
86
86
  // std::vector<uint64_t> ground_truth_matches(
87
87
  // num_iou_thresholds * num_ground_truth, 0);
88
- std::vector<int64_t> &ground_truth_matches =
88
+ std::vector<int64_t>& ground_truth_matches =
89
89
  results->ground_truth_matches;
90
90
  ground_truth_matches.resize(num_iou_thresholds * num_ground_truth, 0);
91
91
 
92
- std::vector<int64_t> &detection_matches = results->detection_matches;
92
+ std::vector<int64_t>& detection_matches = results->detection_matches;
93
93
 
94
- std::vector<bool> &detection_ignores = results->detection_ignores;
95
- std::vector<bool> &ground_truth_ignores = results->ground_truth_ignores;
94
+ std::vector<bool>& detection_ignores = results->detection_ignores;
95
+ std::vector<bool>& ground_truth_ignores = results->ground_truth_ignores;
96
96
  detection_matches.resize(num_iou_thresholds * num_detections, 0);
97
97
  detection_ignores.resize(num_iou_thresholds * num_detections, false);
98
98
  ground_truth_ignores.resize(num_ground_truth);
@@ -166,7 +166,7 @@ void MatchDetectionsToGroundTruth(
166
166
 
167
167
  // set unmatched detections outside of area range to
168
168
  // ignore
169
- const InstanceAnnotation &detection =
169
+ const InstanceAnnotation& detection =
170
170
  detection_instances[detection_sorted_indices[d]];
171
171
  detection_ignores[t * num_detections + d] =
172
172
  detection_ignores[t * num_detections + d] ||
@@ -186,20 +186,15 @@ void MatchDetectionsToGroundTruth(
186
186
  }
187
187
 
188
188
  std::vector<ImageEvaluation> EvaluateImages(
189
- const std::vector<std::array<double, 2>> &area_ranges, int max_detections,
190
- const std::vector<double> &iou_thresholds,
191
- const ImageCategoryInstances<std::vector<double>> &image_category_ious,
192
- const ImageCategoryInstances<InstanceAnnotation>
193
- &image_category_ground_truth_instances,
194
- const ImageCategoryInstances<InstanceAnnotation>
195
- &image_category_detection_instances) {
189
+ const std::vector<std::array<double, 2>>& area_ranges, int max_detections,
190
+ const std::vector<double>& iou_thresholds,
191
+ const ImageCategoryInstances<std::vector<double>>& image_category_ious,
192
+ const LightweightDataset& gt_dataset, const LightweightDataset& dt_dataset,
193
+ const std::vector<double>& img_ids, const std::vector<double>& cat_ids,
194
+ bool useCats) {
196
195
  const int num_area_ranges = (const int)area_ranges.size();
197
- const int num_images =
198
- (const int)image_category_ground_truth_instances.size();
199
- const int num_categories =
200
- (const int)(image_category_ious.size() > 0
201
- ? image_category_ious[0].size()
202
- : 0);
196
+ const int num_images = (const int)img_ids.size();
197
+ const int num_categories = useCats ? (const int)cat_ids.size() : 1;
203
198
  std::vector<uint64_t> detection_sorted_indices;
204
199
  std::vector<uint64_t> ground_truth_sorted_indices;
205
200
  std::vector<bool> ignores;
@@ -211,12 +206,48 @@ std::vector<ImageEvaluation> EvaluateImages(
211
206
  // ImageEvaluation object
212
207
  for (auto i = 0; i < num_images; ++i) {
213
208
  for (auto c = 0; c < num_categories; ++c) {
214
- const std::vector<InstanceAnnotation>
215
- &ground_truth_instances =
216
- image_category_ground_truth_instances[i][c];
217
- const std::vector<InstanceAnnotation>
218
- &detection_instances =
219
- image_category_detection_instances[i][c];
209
+ // Read annotations on-demand from datasets
210
+ double img_id = img_ids[i];
211
+
212
+ std::vector<InstanceAnnotation> ground_truth_instances;
213
+ std::vector<InstanceAnnotation> detection_instances;
214
+
215
+ if (useCats) {
216
+ double cat_id = cat_ids[c];
217
+ ground_truth_instances =
218
+ gt_dataset.get_cpp_annotations(img_id,
219
+ cat_id);
220
+ detection_instances =
221
+ dt_dataset.get_cpp_annotations(img_id,
222
+ cat_id);
223
+ } else {
224
+ // When useCats=False, merge all categories for
225
+ // this image
226
+ for (size_t j = 0; j < cat_ids.size(); ++j) {
227
+ double cat_id = cat_ids[j];
228
+ std::vector<InstanceAnnotation>
229
+ gt_anns =
230
+ gt_dataset.get_cpp_annotations(
231
+ img_id, cat_id);
232
+ std::vector<InstanceAnnotation>
233
+ dt_anns =
234
+ dt_dataset.get_cpp_annotations(
235
+ img_id, cat_id);
236
+
237
+ ground_truth_instances.insert(
238
+ ground_truth_instances.end(),
239
+ std::make_move_iterator(
240
+ gt_anns.begin()),
241
+ std::make_move_iterator(
242
+ gt_anns.end()));
243
+ detection_instances.insert(
244
+ detection_instances.end(),
245
+ std::make_move_iterator(
246
+ dt_anns.begin()),
247
+ std::make_move_iterator(
248
+ dt_anns.end()));
249
+ }
250
+ }
220
251
 
221
252
  SortInstancesByDetectionScore(
222
253
  detection_instances, &detection_sorted_indices);
@@ -241,6 +272,24 @@ std::vector<ImageEvaluation> EvaluateImages(
241
272
  num_images +
242
273
  a * num_images + i]);
243
274
  }
275
+
276
+ // Clear cache entries to free memory after processing
277
+ // all area_ranges
278
+ if (useCats) {
279
+ double cat_id = cat_ids[c];
280
+ gt_dataset.clear_cache_entry(img_id, cat_id);
281
+ dt_dataset.clear_cache_entry(img_id, cat_id);
282
+ } else {
283
+ // When useCats=False, clear cache for all
284
+ // categories used
285
+ for (size_t j = 0; j < cat_ids.size(); ++j) {
286
+ double cat_id = cat_ids[j];
287
+ gt_dataset.clear_cache_entry(img_id,
288
+ cat_id);
289
+ dt_dataset.clear_cache_entry(img_id,
290
+ cat_id);
291
+ }
292
+ }
244
293
  }
245
294
  }
246
295
 
@@ -249,7 +298,7 @@ std::vector<ImageEvaluation> EvaluateImages(
249
298
 
250
299
  // Convert a python list to a vector
251
300
  template <typename T>
252
- std::vector<T> list_to_vec(const py::list &l) {
301
+ std::vector<T> list_to_vec(const py::list& l) {
253
302
  std::vector<T> v(py::len(l));
254
303
  for (int i = 0; i < (int)py::len(l); ++i) {
255
304
  v[i] = l[i].cast<T>();
@@ -269,13 +318,13 @@ std::vector<T> list_to_vec(const py::list &l) {
269
318
  // and is the image_detection_indices[i]'th of the list of detections
270
319
  // for the image containing i. detection_sorted_indices[] defines a sorted
271
320
  // permutation of the 3 other outputs
272
- int BuildSortedDetectionList(const std::vector<ImageEvaluation> &evaluations,
321
+ int BuildSortedDetectionList(const std::vector<ImageEvaluation>& evaluations,
273
322
  const int64_t evaluation_index,
274
323
  const int64_t num_images, const int max_detections,
275
- std::vector<uint64_t> *evaluation_indices,
276
- std::vector<double> *detection_scores,
277
- std::vector<uint64_t> *detection_sorted_indices,
278
- std::vector<uint64_t> *image_detection_indices) {
324
+ std::vector<uint64_t>* evaluation_indices,
325
+ std::vector<double>* detection_scores,
326
+ std::vector<uint64_t>* detection_sorted_indices,
327
+ std::vector<uint64_t>* image_detection_indices) {
279
328
  assert(evaluations.size() >= evaluation_index + num_images);
280
329
 
281
330
  // Extract a list of object instances of the applicable category, area
@@ -288,7 +337,7 @@ int BuildSortedDetectionList(const std::vector<ImageEvaluation> &evaluations,
288
337
  detection_scores->reserve(num_images * max_detections);
289
338
  int num_valid_ground_truth = 0;
290
339
  for (auto i = 0; i < num_images; ++i) {
291
- const ImageEvaluation &evaluation =
340
+ const ImageEvaluation& evaluation =
292
341
  evaluations[evaluation_index + i];
293
342
 
294
343
  for (int d = 0; d < (int)evaluation.detection_scores.size() &&
@@ -333,16 +382,16 @@ int BuildSortedDetectionList(const std::vector<ImageEvaluation> &evaluations,
333
382
  void ComputePrecisionRecallCurve(
334
383
  const int64_t precisions_out_index, const int64_t precisions_out_stride,
335
384
  const int64_t recalls_out_index,
336
- const std::vector<double> &recall_thresholds, const int iou_threshold_index,
385
+ const std::vector<double>& recall_thresholds, const int iou_threshold_index,
337
386
  const int num_iou_thresholds, const int num_valid_ground_truth,
338
- const std::vector<ImageEvaluation> &evaluations,
339
- const std::vector<uint64_t> &evaluation_indices,
340
- const std::vector<double> &detection_scores,
341
- const std::vector<uint64_t> &detection_sorted_indices,
342
- const std::vector<uint64_t> &image_detection_indices,
343
- std::vector<double> *precisions, std::vector<double> *recalls,
344
- std::vector<double> *precisions_out, std::vector<double> *scores_out,
345
- std::vector<double> *recalls_out) {
387
+ const std::vector<ImageEvaluation>& evaluations,
388
+ const std::vector<uint64_t>& evaluation_indices,
389
+ const std::vector<double>& detection_scores,
390
+ const std::vector<uint64_t>& detection_sorted_indices,
391
+ const std::vector<uint64_t>& image_detection_indices,
392
+ std::vector<double>* precisions, std::vector<double>* recalls,
393
+ std::vector<double>* precisions_out, std::vector<double>* scores_out,
394
+ std::vector<double>* recalls_out) {
346
395
  assert(recalls_out->size() > recalls_out_index);
347
396
 
348
397
  // Compute precision/recall for each instance in the sorted list of
@@ -354,7 +403,7 @@ void ComputePrecisionRecallCurve(
354
403
  recalls->reserve(detection_sorted_indices.size());
355
404
  assert(!evaluations.empty() || detection_sorted_indices.empty());
356
405
  for (auto detection_sorted_index : detection_sorted_indices) {
357
- const ImageEvaluation &evaluation =
406
+ const ImageEvaluation& evaluation =
358
407
  evaluations[evaluation_indices[detection_sorted_index]];
359
408
  const auto num_detections =
360
409
  evaluation.detection_matches.size() / num_iou_thresholds;
@@ -424,8 +473,8 @@ void ComputePrecisionRecallCurve(
424
473
  }
425
474
  }
426
475
  }
427
- py::dict Accumulate(const py::object &params,
428
- const std::vector<ImageEvaluation> &evaluations) {
476
+ py::dict Accumulate(const py::object& params,
477
+ const std::vector<ImageEvaluation>& evaluations) {
429
478
  const std::vector<double> recall_thresholds =
430
479
  list_to_vec<double>(params.attr("recThrs"));
431
480
  const std::vector<int> max_detections =
@@ -612,12 +661,11 @@ py::dict Accumulate(const py::object &params,
612
661
  }
613
662
 
614
663
  py::dict EvaluateAccumulate(
615
- const py::object &params,
616
- const ImageCategoryInstances<std::vector<double>> &image_category_ious,
617
- const ImageCategoryInstances<InstanceAnnotation>
618
- &image_category_ground_truth_instances,
619
- const ImageCategoryInstances<InstanceAnnotation>
620
- &image_category_detection_instances) {
664
+ const py::object& params,
665
+ const ImageCategoryInstances<std::vector<double>>& image_category_ious,
666
+ const LightweightDataset& gt_dataset, const LightweightDataset& dt_dataset,
667
+ const std::vector<double>& img_ids, const std::vector<double>& cat_ids,
668
+ bool useCats) {
621
669
  const std::vector<int> max_detections =
622
670
  list_to_vec<int>(params.attr("maxDets"));
623
671
  const std::vector<std::array<double, 2>> area_ranges =
@@ -625,10 +673,10 @@ py::dict EvaluateAccumulate(
625
673
  const std::vector<double> iou_thresholds =
626
674
  list_to_vec<double>(params.attr("iouThrs"));
627
675
 
628
- std::vector<ImageEvaluation> result = EvaluateImages(
629
- area_ranges, max_detections.back(), iou_thresholds,
630
- image_category_ious, image_category_ground_truth_instances,
631
- image_category_detection_instances);
676
+ std::vector<ImageEvaluation> result =
677
+ EvaluateImages(area_ranges, max_detections.back(), iou_thresholds,
678
+ image_category_ious, gt_dataset, dt_dataset, img_ids,
679
+ cat_ids, useCats);
632
680
  return Accumulate(params, result);
633
681
  }
634
682
 
@@ -638,8 +686,8 @@ py::dict EvaluateAccumulate(
638
686
  // non-increasing. Arguments:
639
687
  // recall_list: vector of recall values (must be sorted in increasing order)
640
688
  // precision_list: vector of precision values (same size as recall_list)
641
- long double calc_auc(const std::vector<long double> &recall_list,
642
- const std::vector<long double> &precision_list) {
689
+ long double calc_auc(const std::vector<long double>& recall_list,
690
+ const std::vector<long double>& precision_list) {
643
691
  // Make a copy of precision_list to enforce monotonicity.
644
692
  std::vector<long double> mpre = precision_list;
645
693
 
@@ -8,38 +8,16 @@
8
8
 
9
9
  #include <vector>
10
10
 
11
+ #include "types.h"
12
+
11
13
  namespace py = pybind11;
12
14
 
13
15
  namespace coco_eval {
14
16
 
15
17
  namespace COCOeval {
16
18
 
17
- // Annotation data for a single object instance in an image
18
- struct InstanceAnnotation {
19
- InstanceAnnotation(uint64_t id, double score, double area,
20
- bool is_crowd, bool ignore, bool lvis_mark)
21
- : id{id},
22
- score{score},
23
- area{area},
24
- is_crowd{is_crowd},
25
- ignore{ignore},
26
- lvis_mark{lvis_mark} {}
27
- uint64_t id;
28
- double score = 0.;
29
- double area = 0.;
30
- bool is_crowd = false;
31
- bool ignore = false;
32
- bool lvis_mark = false;
33
- };
34
-
35
- // Stores the match between a detected instance and a ground truth instance
36
- struct MatchedAnnotation {
37
- MatchedAnnotation(uint64_t dt_id, uint64_t gt_id, double iou)
38
- : dt_id{dt_id}, gt_id{gt_id}, iou{iou} {}
39
- uint64_t dt_id;
40
- uint64_t gt_id;
41
- double iou;
42
- };
19
+ // Forward declaration
20
+ class LightweightDataset;
43
21
 
44
22
  // Stores intermediate results for evaluating detection results for a single
45
23
  // image that has D detected instances and G ground truth instances. This stores
@@ -81,32 +59,30 @@ using ImageCategoryInstances = std::vector<std::vector<std::vector<T>>>;
81
59
  // image_category_detection_instances[i][c] is a vector of detected
82
60
  // instances in image image_ids[i] of category category_ids[c]
83
61
  std::vector<ImageEvaluation> EvaluateImages(
84
- const std::vector<std::array<double, 2>>
85
- &area_ranges, // vector of 2-tuples
86
- int max_detections, const std::vector<double> &iou_thresholds,
87
- const ImageCategoryInstances<std::vector<double>> &image_category_ious,
88
- const ImageCategoryInstances<InstanceAnnotation>
89
- &image_category_ground_truth_instances,
90
- const ImageCategoryInstances<InstanceAnnotation>
91
- &image_category_detection_instances);
62
+ const std::vector<std::array<double, 2>>&
63
+ area_ranges, // vector of 2-tuples
64
+ int max_detections, const std::vector<double>& iou_thresholds,
65
+ const ImageCategoryInstances<std::vector<double>>& image_category_ious,
66
+ const LightweightDataset& gt_dataset, const LightweightDataset& dt_dataset,
67
+ const std::vector<double>& img_ids, const std::vector<double>& cat_ids,
68
+ bool useCats);
92
69
 
93
70
  // C++ implementation of COCOeval.accumulate(), which generates precision
94
71
  // recall curves for each set of category, IOU threshold, detection area range,
95
72
  // and max number of detections parameters. It is assumed that the parameter
96
73
  // evaluations is the return value of the functon COCOeval::EvaluateImages(),
97
74
  // which was called with the same parameter settings params
98
- py::dict Accumulate(const py::object &params,
99
- const std::vector<ImageEvaluation> &evalutations);
75
+ py::dict Accumulate(const py::object& params,
76
+ const std::vector<ImageEvaluation>& evalutations);
100
77
 
101
78
  py::dict EvaluateAccumulate(
102
- const py::object &params,
103
- const ImageCategoryInstances<std::vector<double>> &image_category_ious,
104
- const ImageCategoryInstances<InstanceAnnotation>
105
- &image_category_ground_truth_instances,
106
- const ImageCategoryInstances<InstanceAnnotation>
107
- &image_category_detection_instances);
108
-
109
- long double calc_auc(const std::vector<long double> &recall_list,
110
- const std::vector<long double> &precision_list);
79
+ const py::object& params,
80
+ const ImageCategoryInstances<std::vector<double>>& image_category_ious,
81
+ const LightweightDataset& gt_dataset, const LightweightDataset& dt_dataset,
82
+ const std::vector<double>& img_ids, const std::vector<double>& cat_ids,
83
+ bool useCats);
84
+
85
+ long double calc_auc(const std::vector<long double>& recall_list,
86
+ const std::vector<long double>& precision_list);
111
87
  } // namespace COCOeval
112
88
  } // namespace coco_eval