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

Major slowdown for evaluating edges in current main #57

Closed
bentaculum opened this issue Sep 22, 2023 · 2 comments
Closed

Major slowdown for evaluating edges in current main #57

bentaculum opened this issue Sep 22, 2023 · 2 comments

Comments

@bentaculum
Copy link
Contributor

  • traccuracy version: main branch vs f8c982c57b8aa92ac8ab5410318ad2b20c0c6f76
  • Python version: 3.10.13
  • Operating System: Ubuntu 22.04

Description

The recent changes are considerably slowing down the evaluation of FP/FN edges. For the example below, one of the phase contrast datasets from the CTC, I get an estimate of 01:45h. With commit f8c982c57b8aa92ac8ab5410318ad2b20c0c6f76, which I was using until just now, this evaluation gets done in only seconds.

What I Did

I slightly adapted the example, to simply compare GT vs GT of a slightly larger CTC dataset:

import os
from pathlib import Path
import pprint
import urllib.request
import zipfile

from tqdm import tqdm

from traccuracy import run_metrics
from traccuracy.loaders import load_ctc_data
from traccuracy.matchers import CTCMatched, IOUMatched
from traccuracy.metrics import CTCMetrics, DivisionMetrics

pp = pprint.PrettyPrinter(indent=4)

url = "http://data.celltrackingchallenge.net/training-datasets/PhC-C2DL-PSC.zip"
data_dir = "downloads"

if not os.path.exists(data_dir):
    os.mkdir(data_dir)

filename = url.split("/")[-1]
file_path = os.path.join(data_dir, filename)
ds_name = filename.split(".")[0]

# Add a utility to make a progress bar when downloading the file
class DownloadProgressBar(tqdm):
    def update_to(self, b=1, bsize=1, tsize=None):
        if tsize is not None:
            self.total = tsize
        self.update(b * bsize - self.n)


if not os.path.exists(file_path):
    print(f"Downloading {ds_name} data from the CTC website")
    # Downloading data
    with DownloadProgressBar(
        unit="B", unit_scale=True, miniters=1, desc=url.split("/")[-1]
    ) as t:
        urllib.request.urlretrieve(url, file_path, reporthook=t.update_to)
    # Unzip the data
    # TODO add a progress bar to zip as well
    with zipfile.ZipFile(file_path, "r") as zip_ref:
        zip_ref.extractall(data_dir)


gt_data = load_ctc_data(
    "downloads/PhC-C2DL-PSC/01_GT/TRA", "downloads/PhC-C2DL-PSC/01_GT/TRA/man_track.txt"
)
pred_data = load_ctc_data(
    "downloads/PhC-C2DL-PSC/01_GT/TRA", "downloads/PhC-C2DL-PSC/01_GT/TRA/man_track.txt"
)

ctc_results = run_metrics(gt_data=gt_data, pred_data=pred_data, matcher=CTCMatched, metrics=[CTCMetrics, DivisionMetrics],)
pp.pprint(ctc_results)
@bentaculum
Copy link
Contributor Author

I am proposing a solution in #59.

@bentaculum
Copy link
Contributor Author

Solved and merged in #59, closing.

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

No branches or pull requests

1 participant