Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ece613-lost
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Spencer Delcore
ece613-lost
Commits
99564e18
Commit
99564e18
authored
1 year ago
by
apsakinmukomi
Browse files
Options
Downloads
Patches
Plain Diff
- Added code for ap50 calculation
parent
0c48e25d
No related branches found
No related tags found
1 merge request
!1
- Added code for ap50 calculation
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main_lost.py
+20
-2
20 additions, 2 deletions
main_lost.py
with
20 additions
and
2 deletions
main_lost.py
+
20
−
2
View file @
99564e18
...
...
@@ -334,6 +334,12 @@ if __name__ == "__main__":
if
args
.
no_evaluation
:
continue
# Initialize variables for AP50 calculation
tp
=
0
fp
=
0
total_gt_boxes
=
len
(
gt_bbxs
)
ap50
=
0
# Compare prediction to GT boxes
for
pred
in
preds
:
if
len
(
preds
)
==
0
:
...
...
@@ -345,19 +351,31 @@ if __name__ == "__main__":
ious
=
bbox_iou
(
torch
.
from_numpy
(
pred
),
torch
.
from_numpy
(
np
.
asarray
(
gt_bbxs
)))
# TODO: This calculates the corloc
# we need to calculate the AP50
if
torch
.
any
(
ious
>=
0.50
):
#corloc[im_id] = 1
corloc
[
im_id
]
=
0
for
i
in
ious
:
if
i
>=
0.50
:
corloc
[
im_id
]
+=
1
corloc
[
im_id
]
+=
1
# Count true positives and false positives at IoU threshold of 0.5
if
torch
.
any
(
ious
>=
0.50
):
tp
+=
1
else
:
fp
+=
1
cnt
+=
len
(
gt_bbxs
)
if
cnt
%
50
==
0
:
pbar
.
set_description
(
f
"
Found
{
int
(
np
.
sum
(
corloc
))
}
/
{
cnt
}
"
)
# Calculate precision and recall at IoU threshold of 0.5
precision
=
tp
/
(
tp
+
fp
)
recall
=
tp
/
total_gt_boxes
# Calculate AP50 as average precision at IoU threshold of 0.5
ap50
=
precision
*
recall
print
(
f
"
AP50:
{
ap50
:
.
2
f
}
"
)
# Save predicted bounding boxes
if
args
.
save_predictions
:
...
...
This diff is collapsed.
Click to expand it.
Oluwaseun Akinmukomi
@oakinmuk
mentioned in commit
8fc57a85
·
1 year ago
mentioned in commit
8fc57a85
mentioned in commit 8fc57a857ed53fac5d7f47ac6a2f45ad05273316
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment