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

Use logging API #58

Merged
merged 1 commit into from
Sep 27, 2023
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
13 changes: 8 additions & 5 deletions src/traccuracy/cli.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import json
import logging
from typing import Optional

import typer

from traccuracy import run_metrics
from traccuracy.loaders import load_ctc_data

logger = logging.getLogger(__name__)

app = typer.Typer()


Expand Down Expand Up @@ -57,8 +60,8 @@ def run_ctc(
result = run_metrics(gt_data, pred_data, CTCMatched, [CTCMetrics])
with open(out_path, "w") as fp:
json.dump(result, fp)
print(f'TRA: {result["CTCMetrics"]["TRA"]}')
print(f'DET: {result["CTCMetrics"]["DET"]}')
logger.info(f'TRA: {result["CTCMetrics"]["TRA"]}')
logger.info(f'DET: {result["CTCMetrics"]["DET"]}')


@app.command()
Expand Down Expand Up @@ -130,7 +133,7 @@ def run_aogm(
)
with open(out_path, "w") as fp:
json.dump(result, fp)
print(f'AOGM: {result["AOGMMetrics"]["AOGM"]}')
logger.info(f'AOGM: {result["AOGMMetrics"]["AOGM"]}')


@app.command()
Expand Down Expand Up @@ -194,7 +197,7 @@ def run_divisions_on_iou(
res_str = ""
for frame_buffer, res_dict in result["DivisionMetrics"].items():
res_str += f'{frame_buffer} F1: {res_dict["Division F1"]}\n'
print(res_str)
logger.info(res_str)


@app.command()
Expand Down Expand Up @@ -252,7 +255,7 @@ def run_divisions_on_ctc(
res_str = ""
for frame_buffer, res_dict in result["DivisionMetrics"].items():
res_str += f'{frame_buffer} F1: {res_dict["Division F1"]}\n'
print(res_str)
logger.info(res_str)


typer_click_object = typer.main.get_command(app)
Expand Down
7 changes: 5 additions & 2 deletions src/traccuracy/matchers/_matched.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import logging
from abc import ABC, abstractmethod

from traccuracy._tracking_graph import TrackingGraph

logger = logging.getLogger(__name__)


class Matched(ABC):
def __init__(self, gt_graph: "TrackingGraph", pred_graph: "TrackingGraph"):
Expand All @@ -25,8 +28,8 @@ def __init__(self, gt_graph: "TrackingGraph", pred_graph: "TrackingGraph"):
matched_gt = len({m[0] for m in self.mapping})
total_pred = len(self.pred_graph.nodes())
matched_pred = len({m[1] for m in self.mapping})
print(f"Matched {matched_gt} out of {total_gt} ground truth nodes.")
print(f"Matched {matched_pred} out of {total_pred} predicted nodes.")
logger.info(f"Matched {matched_gt} out of {total_gt} ground truth nodes.")
logger.info(f"Matched {matched_pred} out of {total_pred} predicted nodes.")

@abstractmethod
def compute_mapping(self):
Expand Down