-
Notifications
You must be signed in to change notification settings - Fork 132
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 torchmetrics to calculate map #99
base: main
Are you sure you want to change the base?
Use torchmetrics to calculate map #99
Conversation
Thank you for your contribution! Next, I will proceed with a code review for each block. Please direct push this to the Best regards, |
I would just like to mention that torch metrics[detection] is a wrapper around pycocotools SEE THIS
|
@@ -134,16 +134,16 @@ def load_valid_labels(self, label_path: str, seg_data_one_img: list) -> Union[Te | |||
def get_data(self, idx): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add return types please?
@@ -134,16 +134,16 @@ def load_valid_labels(self, label_path: str, seg_data_one_img: list) -> Union[Te | |||
def get_data(self, idx): | |||
img_path, bboxes = self.data[idx] | |||
img = Image.open(img_path).convert("RGB") | |||
return img, bboxes, img_path | |||
return img, bboxes | |||
|
|||
def get_more_data(self, num: int = 1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add return types please?
@@ -227,7 +227,19 @@ def __call__(self, target: Tensor, predict: Tuple[Tensor]) -> Tuple[Tensor, Tens | |||
2. Select the targets | |||
2. Noramlize the class probilities of targets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2. Noramlize the class probilities of targets | |
2. Normalize the class probabilities of targets |
ap_table.add_row(f"{epoch: 3d}", ap_name, f"{ap_color}{ap_value:.2f}", ar_name, f"{ar_color}{ar_value:.2f}") | ||
|
||
return ap_table, this_ap | ||
def format_prediction(prediction: torch.Tensor) -> dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for better typing you should better annotate the return type here. Something like below (not exact) to provide at least a little bit better IntelliSense to any contributors:
def format_prediction(prediction: torch.Tensor) -> dict: | |
def format_prediction(prediction: torch.Tensor) -> Dict[str, List[int]]: |
def format_prediction(prediction: torch.Tensor) -> dict: | ||
""" | ||
Format the prediction output to a dictionary. | ||
Args: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Args: | |
Args: |
No description provided.