Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving mota output #180

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open

Saving mota output #180

wants to merge 45 commits into from

Conversation

nikk-nikaznan
Copy link
Collaborator

@nikk-nikaznan nikk-nikaznan commented Jun 4, 2024

  • mota return all the metrics and save to csv
  • adding some plot functions to visualise the tracking result

@nikk-nikaznan nikk-nikaznan marked this pull request as draft June 4, 2024 16:55
@nikk-nikaznan nikk-nikaznan changed the title Saving tracking mota output Saving mota output Jun 4, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jun 4, 2024

Codecov Report

Attention: Patch coverage is 20.58824% with 54 lines in your changes missing coverage. Please review.

Project coverage is 45.67%. Comparing base (8fc0ed8) to head (68a8c2b).

Files Patch % Lines
crabs/tracker/utils/io.py 12.76% 41 Missing ⚠️
crabs/tracker/evaluate_tracker.py 37.50% 10 Missing ⚠️
crabs/tracker/utils/tracking.py 40.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #180      +/-   ##
==========================================
- Coverage   46.13%   45.67%   -0.46%     
==========================================
  Files          24       24              
  Lines        1461     1526      +65     
==========================================
+ Hits          674      697      +23     
- Misses        787      829      +42     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nikk-nikaznan nikk-nikaznan marked this pull request as ready for review July 12, 2024 17:02
Copy link
Collaborator

@sfmig sfmig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks Nik! 🚀

Some small suggestions, and a slightly larger one re the output directory naming.

@@ -299,7 +307,15 @@ def evaluate_mota(
mota = (
1 - (missed_detections + false_positive + num_switches) / total_gt
)
return mota, gt_to_tracked_id_current_frame
return (
mota,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning a long tuple is sometimes considered a code smell.

Maybe we can pass mota and its components as a dict to reduce this?

"Missed Detections": [],
"False Positives": [],
"Number of Switches": [],
"Mota": [],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Mota": [],
"MOTA": [],

gt_data_frame,
pred_data_frame,
self.iou_threshold,
prev_frame_id_map,
)
mota_values.append(mota)
results["Frame Number"].append(frame_number)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we make evaluate_mota return a dict for the MOTA and its components (called for example mota_dict), then we can make results have the same keys. That way we can make this bit smaller:

for key in results.keys():
	results[key].append(mota_dict[key])

@@ -154,6 +156,7 @@ def save_required_output(
frame_copy = frame.copy()
for bbox in tracked_boxes:
xmin, ymin, xmax, ymax, id = bbox
print(f"Calling draw_bbox with {bbox}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print(f"Calling draw_bbox with {bbox}")

mota_value_list.append(float(row["Mota"]))

return (
true_positives_list,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this tuple can be a dict instead? It's a bit less of a code smell

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we read the csv as a pandas dataframe instead we can extract the columns more efficiently (that is, without explicit looping).

There is also a dataframe .to_dict() method, so we may be able to get the output dictionary in one go this way.

plot_name = filepath.name

num_frames = len(true_positives_list)
frames = range(1, num_frames + 1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
frames = range(1, num_frames + 1)
frame_numbers = range(1, num_frames + 1)

track_results: dict[str, Any],
) -> None:
track_df = pd.DataFrame(track_results)
output_filename = f"{tracking_output_dir}/tracking_metrics_output.csv"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to follow our usual convention, could we timestamp the output directory? We would need to ensure it goes in the same directory as the video output if requested (or other outputs that may be requested)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants