Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ assignees: ''
---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when \[...\]
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ jobs:
- os: windows-latest
cibw_archs: ARM64
cibw_skip: "pp*"
- os: macos-13
cibw_archs: x86_64
cibw_skip: "pp*"
- os: macos-14
cibw_archs: arm64
cibw_skip: "pp*"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.13'

- name: Install pandoc
run: sudo apt-get update && sudo apt-get install -y pandoc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: False
matrix:
os: [ubuntu-latest, macos-14, windows-latest]
pythonv: ["3.8", "3.x"]
pythonv: ["3.8", "3.13"]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.13"

- name: Install from sdist
shell: bash
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: end-of-file-fixer
exclude: "csrc/faster_eval_api/coco_eval/json\\.hpp"
Expand All @@ -22,14 +22,14 @@ repos:
- id: detect-private-key

- repo: https://github.com/PyCQA/docformatter
rev: 06907d0
rev: v1.7.7
hooks:
- id: docformatter
additional_dependencies: [tomli]
args: ["--in-place"]

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
rev: 0.7.19
hooks:
- id: mdformat
args: ["--number"]
Expand All @@ -39,7 +39,7 @@ repos:
- mdformat_frontmatter

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
rev: v0.14.10
hooks:
- id: ruff
args: ["--fix"]
Expand All @@ -48,7 +48,7 @@ repos:

# C++: clang-format (autoformatting)
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.6
rev: v21.1.8
hooks:
- id: clang-format
args: ["-style={BasedOnStyle: Google, IndentWidth: 8}", "--fallback-style=Google"]
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
Expand Down
100 changes: 50 additions & 50 deletions csrc/faster_eval_api/coco_eval/cocoeval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace coco_eval {

namespace COCOeval {
template <typename T>
int64_t v_index(const std::vector<T> &v, const T &key) {
int64_t v_index(const std::vector<T>& v, const T& key) {
auto itr = std::find(v.begin(), v.end(), key);

if (itr != v.cend()) {
Expand All @@ -29,8 +29,8 @@ int64_t v_index(const std::vector<T> &v, const T &key) {
// detection_instances[detection_sorted_indices[t+1]]. Use stable_sort to match
// original COCO API
void SortInstancesByDetectionScore(
const std::vector<InstanceAnnotation> &detection_instances,
std::vector<uint64_t> *detection_sorted_indices) {
const std::vector<InstanceAnnotation>& detection_instances,
std::vector<uint64_t>* detection_sorted_indices) {
detection_sorted_indices->resize(detection_instances.size());
std::iota(detection_sorted_indices->begin(),
detection_sorted_indices->end(), 0);
Expand All @@ -45,10 +45,10 @@ void SortInstancesByDetectionScore(
// Partition the ground truth objects based on whether or not to ignore them
// based on area
void SortInstancesByIgnore(
const std::array<double, 2> &area_range,
const std::vector<InstanceAnnotation> &ground_truth_instances,
std::vector<uint64_t> *ground_truth_sorted_indices,
std::vector<bool> *ignores) {
const std::array<double, 2>& area_range,
const std::vector<InstanceAnnotation>& ground_truth_instances,
std::vector<uint64_t>* ground_truth_sorted_indices,
std::vector<bool>* ignores) {
ignores->clear();
ignores->reserve(ground_truth_instances.size());
for (auto o : ground_truth_instances) {
Expand All @@ -70,29 +70,29 @@ void SortInstancesByIgnore(
// For each IOU threshold, greedily match each detected instance to a ground
// truth instance (if possible) and store the results
void MatchDetectionsToGroundTruth(
const std::vector<InstanceAnnotation> &detection_instances,
const std::vector<uint64_t> &detection_sorted_indices,
const std::vector<InstanceAnnotation> &ground_truth_instances,
const std::vector<uint64_t> &ground_truth_sorted_indices,
const std::vector<bool> &ignores,
const std::vector<std::vector<double>> &ious,
const std::vector<double> &iou_thresholds,
const std::array<double, 2> &area_range, ImageEvaluation *results) {
const std::vector<InstanceAnnotation>& detection_instances,
const std::vector<uint64_t>& detection_sorted_indices,
const std::vector<InstanceAnnotation>& ground_truth_instances,
const std::vector<uint64_t>& ground_truth_sorted_indices,
const std::vector<bool>& ignores,
const std::vector<std::vector<double>>& ious,
const std::vector<double>& iou_thresholds,
const std::array<double, 2>& area_range, ImageEvaluation* results) {
// Initialize memory to store return data matches and ignore
const int num_iou_thresholds = (const int)iou_thresholds.size();
const int num_ground_truth =
(const int)ground_truth_sorted_indices.size();
const int num_detections = (const int)detection_sorted_indices.size();
// std::vector<uint64_t> ground_truth_matches(
// num_iou_thresholds * num_ground_truth, 0);
std::vector<int64_t> &ground_truth_matches =
std::vector<int64_t>& ground_truth_matches =
results->ground_truth_matches;
ground_truth_matches.resize(num_iou_thresholds * num_ground_truth, 0);

std::vector<int64_t> &detection_matches = results->detection_matches;
std::vector<int64_t>& detection_matches = results->detection_matches;

std::vector<bool> &detection_ignores = results->detection_ignores;
std::vector<bool> &ground_truth_ignores = results->ground_truth_ignores;
std::vector<bool>& detection_ignores = results->detection_ignores;
std::vector<bool>& ground_truth_ignores = results->ground_truth_ignores;
detection_matches.resize(num_iou_thresholds * num_detections, 0);
detection_ignores.resize(num_iou_thresholds * num_detections, false);
ground_truth_ignores.resize(num_ground_truth);
Expand Down Expand Up @@ -166,7 +166,7 @@ void MatchDetectionsToGroundTruth(

// set unmatched detections outside of area range to
// ignore
const InstanceAnnotation &detection =
const InstanceAnnotation& detection =
detection_instances[detection_sorted_indices[d]];
detection_ignores[t * num_detections + d] =
detection_ignores[t * num_detections + d] ||
Expand All @@ -186,11 +186,11 @@ void MatchDetectionsToGroundTruth(
}

std::vector<ImageEvaluation> EvaluateImages(
const std::vector<std::array<double, 2>> &area_ranges, int max_detections,
const std::vector<double> &iou_thresholds,
const ImageCategoryInstances<std::vector<double>> &image_category_ious,
const LightweightDataset &gt_dataset, const LightweightDataset &dt_dataset,
const std::vector<double> &img_ids, const std::vector<double> &cat_ids,
const std::vector<std::array<double, 2>>& area_ranges, int max_detections,
const std::vector<double>& iou_thresholds,
const ImageCategoryInstances<std::vector<double>>& image_category_ious,
const LightweightDataset& gt_dataset, const LightweightDataset& dt_dataset,
const std::vector<double>& img_ids, const std::vector<double>& cat_ids,
bool useCats) {
const int num_area_ranges = (const int)area_ranges.size();
const int num_images = (const int)img_ids.size();
Expand Down Expand Up @@ -298,7 +298,7 @@ std::vector<ImageEvaluation> EvaluateImages(

// Convert a python list to a vector
template <typename T>
std::vector<T> list_to_vec(const py::list &l) {
std::vector<T> list_to_vec(const py::list& l) {
std::vector<T> v(py::len(l));
for (int i = 0; i < (int)py::len(l); ++i) {
v[i] = l[i].cast<T>();
Expand All @@ -318,13 +318,13 @@ std::vector<T> list_to_vec(const py::list &l) {
// and is the image_detection_indices[i]'th of the list of detections
// for the image containing i. detection_sorted_indices[] defines a sorted
// permutation of the 3 other outputs
int BuildSortedDetectionList(const std::vector<ImageEvaluation> &evaluations,
int BuildSortedDetectionList(const std::vector<ImageEvaluation>& evaluations,
const int64_t evaluation_index,
const int64_t num_images, const int max_detections,
std::vector<uint64_t> *evaluation_indices,
std::vector<double> *detection_scores,
std::vector<uint64_t> *detection_sorted_indices,
std::vector<uint64_t> *image_detection_indices) {
std::vector<uint64_t>* evaluation_indices,
std::vector<double>* detection_scores,
std::vector<uint64_t>* detection_sorted_indices,
std::vector<uint64_t>* image_detection_indices) {
assert(evaluations.size() >= evaluation_index + num_images);

// Extract a list of object instances of the applicable category, area
Expand All @@ -337,7 +337,7 @@ int BuildSortedDetectionList(const std::vector<ImageEvaluation> &evaluations,
detection_scores->reserve(num_images * max_detections);
int num_valid_ground_truth = 0;
for (auto i = 0; i < num_images; ++i) {
const ImageEvaluation &evaluation =
const ImageEvaluation& evaluation =
evaluations[evaluation_index + i];

for (int d = 0; d < (int)evaluation.detection_scores.size() &&
Expand Down Expand Up @@ -382,16 +382,16 @@ int BuildSortedDetectionList(const std::vector<ImageEvaluation> &evaluations,
void ComputePrecisionRecallCurve(
const int64_t precisions_out_index, const int64_t precisions_out_stride,
const int64_t recalls_out_index,
const std::vector<double> &recall_thresholds, const int iou_threshold_index,
const std::vector<double>& recall_thresholds, const int iou_threshold_index,
const int num_iou_thresholds, const int num_valid_ground_truth,
const std::vector<ImageEvaluation> &evaluations,
const std::vector<uint64_t> &evaluation_indices,
const std::vector<double> &detection_scores,
const std::vector<uint64_t> &detection_sorted_indices,
const std::vector<uint64_t> &image_detection_indices,
std::vector<double> *precisions, std::vector<double> *recalls,
std::vector<double> *precisions_out, std::vector<double> *scores_out,
std::vector<double> *recalls_out) {
const std::vector<ImageEvaluation>& evaluations,
const std::vector<uint64_t>& evaluation_indices,
const std::vector<double>& detection_scores,
const std::vector<uint64_t>& detection_sorted_indices,
const std::vector<uint64_t>& image_detection_indices,
std::vector<double>* precisions, std::vector<double>* recalls,
std::vector<double>* precisions_out, std::vector<double>* scores_out,
std::vector<double>* recalls_out) {
assert(recalls_out->size() > recalls_out_index);

// Compute precision/recall for each instance in the sorted list of
Expand All @@ -403,7 +403,7 @@ void ComputePrecisionRecallCurve(
recalls->reserve(detection_sorted_indices.size());
assert(!evaluations.empty() || detection_sorted_indices.empty());
for (auto detection_sorted_index : detection_sorted_indices) {
const ImageEvaluation &evaluation =
const ImageEvaluation& evaluation =
evaluations[evaluation_indices[detection_sorted_index]];
const auto num_detections =
evaluation.detection_matches.size() / num_iou_thresholds;
Expand Down Expand Up @@ -473,8 +473,8 @@ void ComputePrecisionRecallCurve(
}
}
}
py::dict Accumulate(const py::object &params,
const std::vector<ImageEvaluation> &evaluations) {
py::dict Accumulate(const py::object& params,
const std::vector<ImageEvaluation>& evaluations) {
const std::vector<double> recall_thresholds =
list_to_vec<double>(params.attr("recThrs"));
const std::vector<int> max_detections =
Expand Down Expand Up @@ -661,10 +661,10 @@ py::dict Accumulate(const py::object &params,
}

py::dict EvaluateAccumulate(
const py::object &params,
const ImageCategoryInstances<std::vector<double>> &image_category_ious,
const LightweightDataset &gt_dataset, const LightweightDataset &dt_dataset,
const std::vector<double> &img_ids, const std::vector<double> &cat_ids,
const py::object& params,
const ImageCategoryInstances<std::vector<double>>& image_category_ious,
const LightweightDataset& gt_dataset, const LightweightDataset& dt_dataset,
const std::vector<double>& img_ids, const std::vector<double>& cat_ids,
bool useCats) {
const std::vector<int> max_detections =
list_to_vec<int>(params.attr("maxDets"));
Expand All @@ -686,8 +686,8 @@ py::dict EvaluateAccumulate(
// non-increasing. Arguments:
// recall_list: vector of recall values (must be sorted in increasing order)
// precision_list: vector of precision values (same size as recall_list)
long double calc_auc(const std::vector<long double> &recall_list,
const std::vector<long double> &precision_list) {
long double calc_auc(const std::vector<long double>& recall_list,
const std::vector<long double>& precision_list) {
// Make a copy of precision_list to enforce monotonicity.
std::vector<long double> mpre = precision_list;

Expand Down
28 changes: 14 additions & 14 deletions csrc/faster_eval_api/coco_eval/cocoeval.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,30 +59,30 @@ using ImageCategoryInstances = std::vector<std::vector<std::vector<T>>>;
// image_category_detection_instances[i][c] is a vector of detected
// instances in image image_ids[i] of category category_ids[c]
std::vector<ImageEvaluation> EvaluateImages(
const std::vector<std::array<double, 2>>
&area_ranges, // vector of 2-tuples
int max_detections, const std::vector<double> &iou_thresholds,
const ImageCategoryInstances<std::vector<double>> &image_category_ious,
const LightweightDataset &gt_dataset, const LightweightDataset &dt_dataset,
const std::vector<double> &img_ids, const std::vector<double> &cat_ids,
const std::vector<std::array<double, 2>>&
area_ranges, // vector of 2-tuples
int max_detections, const std::vector<double>& iou_thresholds,
const ImageCategoryInstances<std::vector<double>>& image_category_ious,
const LightweightDataset& gt_dataset, const LightweightDataset& dt_dataset,
const std::vector<double>& img_ids, const std::vector<double>& cat_ids,
bool useCats);

// C++ implementation of COCOeval.accumulate(), which generates precision
// recall curves for each set of category, IOU threshold, detection area range,
// and max number of detections parameters. It is assumed that the parameter
// evaluations is the return value of the functon COCOeval::EvaluateImages(),
// which was called with the same parameter settings params
py::dict Accumulate(const py::object &params,
const std::vector<ImageEvaluation> &evalutations);
py::dict Accumulate(const py::object& params,
const std::vector<ImageEvaluation>& evalutations);

py::dict EvaluateAccumulate(
const py::object &params,
const ImageCategoryInstances<std::vector<double>> &image_category_ious,
const LightweightDataset &gt_dataset, const LightweightDataset &dt_dataset,
const std::vector<double> &img_ids, const std::vector<double> &cat_ids,
const py::object& params,
const ImageCategoryInstances<std::vector<double>>& image_category_ious,
const LightweightDataset& gt_dataset, const LightweightDataset& dt_dataset,
const std::vector<double>& img_ids, const std::vector<double>& cat_ids,
bool useCats);

long double calc_auc(const std::vector<long double> &recall_list,
const std::vector<long double> &precision_list);
long double calc_auc(const std::vector<long double>& recall_list,
const std::vector<long double>& precision_list);
} // namespace COCOeval
} // namespace coco_eval
Loading
Loading