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

Comet Image Logging Fix #9498

Merged
merged 2 commits into from
Sep 19, 2022
Merged
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
11 changes: 8 additions & 3 deletions utils/loggers/comet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
comet_ml = None
COMET_PROJECT_NAME = None

import PIL
import torch
import torchvision.transforms as T
import yaml
Expand Down Expand Up @@ -131,6 +132,8 @@ def __init__(self, opt, hyp, run_id=None, job_type="Training", **experiment_kwar
else:
self.iou_thres = IOU_THRES

self.log_parameters({"val_iou_threshold": self.iou_thres, "val_conf_threshold": self.conf_thres})

self.comet_log_predictions = COMET_LOG_PREDICTIONS
if self.opt.bbox_interval == -1:
self.comet_log_prediction_interval = 1 if self.opt.epochs < 10 else self.opt.epochs // 10
Expand All @@ -139,6 +142,7 @@ def __init__(self, opt, hyp, run_id=None, job_type="Training", **experiment_kwar

if self.comet_log_predictions:
self.metadata_dict = {}
self.logged_image_names = []

self.comet_log_per_class_metrics = COMET_LOG_PER_CLASS_METRICS

Expand Down Expand Up @@ -249,11 +253,12 @@ def log_predictions(self, image, labelsn, path, shape, predn):
filtered_detections = detections[mask]
filtered_labels = labelsn[mask]

processed_image = (image * 255).to(torch.uint8)

image_id = path.split("/")[-1].split(".")[0]
image_name = f"{image_id}_curr_epoch_{self.experiment.curr_epoch}"
self.log_image(to_pil(processed_image), name=image_name)
if image_name not in self.logged_image_names:
native_scale_image = PIL.Image.open(path)
self.log_image(native_scale_image, name=image_name)
self.logged_image_names.append(image_name)

metadata = []
for cls, *xyxy in filtered_labels.tolist():
Expand Down