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

Model analysis in Object Detection #312

Closed
wants to merge 25 commits into from

Conversation

jyrainer
Copy link

@jyrainer jyrainer commented Mar 6, 2024

  • Changed
    • When evaluate in Object Detection task

      1. Confusion matrix calculation and visualization.
      2. Calculate TP, FP, FN, F1 value and add to results (evaluate.json).
      3. Added draw option. To analyze mispredictions, You can compare the prediction and label through images. Left: Pred / Right: Label
    • When evaluate in Classification task,

      1. Confusion matrix visualization.
    • Add hub cached properties : confusionmatrix_file, mis_predict_dir, fp_dir and fn_dir.

    • Add save_images function, in utils.image.io.

Ref : https://www.notion.so/snuailab/0a2a29ce014f42fb84520057a2eb5500

  • confusion_matrix
    • confusion_matrix
  • misprediction - false positive
    • 2292

)

else:
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

i think it is better to print a Warning or Info message instead of pass.

Copy link
Author

Choose a reason for hiding this comment

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

I'll change it to display a warning message using 'warnings'.

@@ -21,6 +21,18 @@ def save_image(output_path: Union[str, Path], image: Mat, create_directory: bool
with open(str(output_path), mode="w+b") as f:
img_arr.tofile(f)

def save_images(output_path: Union[str, Path], images: list[Mat], create_directory: bool = False) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

it seems better to change the function name. Functionally, it appears to merge multiple images into one and save them as a single image. However, based on the function name alone, it looks like it saves each image individually into separate directories.

Copy link
Author

Choose a reason for hiding this comment

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

I would consider naming it batch_save_images. Thank you for participating in the review!

Copy link
Contributor

Choose a reason for hiding this comment

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

I think..
I'm also confused about batch_save_images naming.
How about naming it save_concat_image?

Copy link
Contributor

@ZeroAct ZeroAct left a comment

Choose a reason for hiding this comment

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

For now, waffle_hub will not approve any PR. But, this PR will be reused when rebuilding sprint be done.

Don't need to make changes about my review.

Comment on lines 22 to 25
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sn
Copy link
Contributor

Choose a reason for hiding this comment

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

remove unused modules

@@ -1364,23 +1391,86 @@ def evaluating(
metrics = evaluate_function(
preds, labels, self.task, len(self.categories), image_size=cfg.image_size
)
# TODO: Confusion matrix visualization functions other than 'OBJECT_DETECTION' and 'CLASSIFICATION' are required.
if self.task == "OBJECT_DETECTION" or self.task == "CLASSIFICATION":
Copy link
Contributor

Choose a reason for hiding this comment

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

use TaskType instead

Comment on lines 1406 to 1434
if value == None:
continue
elif isinstance(value, list):
if len(self.get_category_names()) == len(value) - 1:
"""for object detection confusion matrix"""
values = [
{
"class_name": cat,
"value": cat_value,
}
for cat, cat_value in zip(self.get_category_names(), value)
]
values.append({"class_name": "background", "value": value[-1]})
else:
values = [
{
"class_name": cat,
"value": cat_value,
}
for cat, cat_value in zip(self.get_category_names(), value)
]
elif isinstance(value, set):
"""It can load the misprediction image info."""
values = []
pred_list = list(value)
set_file = io.load_json(getattr(dataset, f"{cfg.set_name}_set_file"))
for pred in pred_list:
image_info = dataset.image_dict[set_file[pred]]
values.append({pred: image_info.file_name})
Copy link
Contributor

Choose a reason for hiding this comment

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

these if-elif condition looks ambiguous

@jyrainer
Copy link
Author

@ZeroAct
The changes have been corrected.
If there is anything else to fix, please let me know.
Later, I hope this will help you complete your "waffle"! 🤗
Thank you for participating in the review!

Copy link
Contributor

@Jiyong-Jeon Jiyong-Jeon left a comment

Choose a reason for hiding this comment

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

Currently, waffle_hub does not approve PR, but I am fixing it with a separate branch for waffle_app.
The pr is necessary for waffle_app, so I will revise it myself and use it.
Please check here. @jyrainer

I will comment the part to consider, so please refer to it when making New Waffle. @ZeroAct

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should also save the Evaluate dataset information. (such as name, root_dir etc..)

Comment on lines +23 to +25
tpfpfn_table: list[float] = None
fp_images_set: set = None
fn_images_set: set = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary for evaluation.json? In particular, I seems that images set is not needed or saved as separate files.

Copy link
Author

Choose a reason for hiding this comment

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

I think the same. I think it would be better to separate it into files according to the image index...

Copy link
Contributor

Choose a reason for hiding this comment

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

I think getf1, getConfusionMatric can be confused with classification.
You divided the folder structure for object detection, but isn't it necessary in common?
I'll think about this part at the same time as I verify it.

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

Successfully merging this pull request may close these issues.

4 participants