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

Misc small fixes #213

Merged
merged 3 commits into from
Nov 22, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _format_images(self, images: Tensor) -> Tensor:
return images

def _format_labels(self, labels: Tensor) -> Tensor:
labels = labels.squeeze((1, -1)) # If (BS, 1, H, W) or (BS, H, W, 1) -> (BS, H, W)
labels = labels.squeeze(1).squeeze(-1) # If (BS, 1, H, W) or (BS, H, W, 1) -> (BS, H, W)
if labels.ndim == 3:
labels = ensure_hard_labels(labels, n_classes=self.data_config.get_n_classes(), threshold_value=self.threshold_value)
elif labels.ndim == 4:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def _compute_cumulative_counts_at_thresholds(self, df: pd.DataFrame, class_names
return counts

def aggregate(self) -> Feature:

df = pd.DataFrame(self.data).sort_values(by="class_id")

bins = np.linspace(0, 1, self.num_bins + 1)
Expand Down Expand Up @@ -96,8 +97,7 @@ def aggregate(self) -> Feature:
xticklabels = [f"IoU < {bins[x]:.2f}" for x in range(1, len(bins))]

if not data:
self._show_plot = False
return Feature(data=None, plot_options=None, json={})
return Feature(data=None, plot_options=None, json={}, title="Intersection of Bounding Boxes", description="No Overlap between any class")

# Height of the plot is proportional to the number of classes
figsize_x = min(max(10, len(bins)), 25)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def update(self, sample: SegmentationSample):
self.class_names = sample.class_names

# (H, W) -> (C, H, W)
n_classes = np.max(sample.mask)
n_classes = np.max(list(sample.class_names.keys()))
mask_onehot = mask_to_onehot(mask_categorical=sample.mask, n_classes=n_classes)
mask_onehot = mask_onehot.transpose((1, 2, 0)) # H, W, C -> C, H, W

Expand Down
17 changes: 9 additions & 8 deletions src/data_gradients/managers/abstract_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,16 @@ def post_process(self, interrupted=False):
else:
warning = feature.warning

section.add_feature(
FeatureSummary(
name=feature.title,
description=self._format_feature_description(feature.description),
image_path=image_path,
warning=warning,
notice=feature.notice,
if not feature_error:
section.add_feature(
FeatureSummary(
name=feature.title,
description=self._format_feature_description(feature.description),
image_path=image_path,
warning=warning,
notice=feature.notice,
)
)
)
summary.add_section(section)

print("Dataset successfully analyzed!")
Expand Down