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

Update kaleido and plotly versions #163

Merged
merged 3 commits into from
Aug 30, 2021
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
9 changes: 3 additions & 6 deletions pyodi/apps/ground_truth.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,12 @@
from pathlib import Path
from typing import Optional, Tuple

from loguru import logger

from pyodi.core.boxes import add_centroids
from pyodi.core.utils import coco_ground_truth_to_df
from pyodi.plots.boxes import get_centroids_heatmap, plot_heatmap
from pyodi.plots.common import plot_scatter_with_histograms


@logger.catch
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@daavoo this was catching all exceptions without reraising anything... so if something crashes, tests simply skips it. Can't recall why did we add this

Copy link
Collaborator

Choose a reason for hiding this comment

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

It should be: logger.catch(reraise=True)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should remove all those decorator.

This is useful to ensure unexpected exceptions are logged, the entire program can be wrapped by this method
https://loguru.readthedocs.io/en/stable/api/logger.html#loguru._logger.Logger.catch

I am not seeing any advantage on using this here

Copy link
Collaborator

@daavoo daavoo Aug 30, 2021

Choose a reason for hiding this comment

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

As you wish. With reraise=True the exceptions would work as without the decorator. In the past, I had found the additional information showed by loguru useful for debugging exceptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I'll remove all those decorators in a different issue, let's merge this for now

def ground_truth(
ground_truth_file: str,
show: bool = True,
Expand Down Expand Up @@ -87,7 +84,7 @@ def ground_truth(
df_images,
x="img_width",
y="img_height",
title=f"{Path(ground_truth_file).stem}: Image Shapes",
title="Image_Shapes",
show=show,
output=output,
output_size=output_size,
Expand All @@ -108,7 +105,7 @@ def ground_truth(
df_annotations,
x="absolute_width",
y="absolute_height",
title=f"{Path(ground_truth_file).stem}: Bounding Box Shapes",
title="Bounding_Box_Shapes",
show=show,
output=output,
output_size=output_size,
Expand All @@ -120,7 +117,7 @@ def ground_truth(

plot_heatmap(
get_centroids_heatmap(df_annotations),
title=f"{Path(ground_truth_file).stem}: Bounding Box Centers",
title="Bounding_Box_Centers",
show=show,
output=output,
output_size=output_size,
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ install_requires =
numba==0.52.0
pandas==1.2.1
pillow==8.1.0
plotly==4.14.3
plotly==5.2.2
pycocotools==2.0.2
kaleido==v0.1.0
kaleido==v0.2.1
scikit-learn==0.24.1
fire==0.4.0

Expand Down
27 changes: 27 additions & 0 deletions tests/apps/test_ground_truth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import json
from pathlib import Path

from pyodi.apps.ground_truth import ground_truth


def test_ground_truth_saves_output_to_files(tmpdir):
output = tmpdir.mkdir("results")

categories = [{"id": 1, "name": "drone"}]
images = [{"id": 0, "file_name": "image.jpg", "height": 10, "width": 10}]
annotations = [
{"image_id": 0, "category_id": 1, "id": 0, "bbox": [0, 0, 5, 5], "area": 25}
]
coco_data = dict(
images=images,
annotations=annotations,
categories=categories,
info={},
licenses={},
)
with open(tmpdir / "data.json", "w") as f:
json.dump(coco_data, f)

ground_truth(tmpdir / "data.json", show=False, output=output)

assert len(list(Path(output / "data").iterdir())) == 3