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

➕Add warnings ⚠️ for inproper task setting in config files. #274

Merged
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
12 changes: 11 additions & 1 deletion anomalib/data/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# and limitations under the License.

import logging
import warnings
from pathlib import Path
from typing import Dict, Optional, Tuple, Union

Expand Down Expand Up @@ -221,11 +222,20 @@ def __init__(
"""
self.split = split

if task == "segmentation" and mask_dir is None:
warnings.warn(
"Segmentation task is requested, but mask directory is not provided. "
"Classification is to be chosen if mask directory is not provided."
)
self.task = "classification"

ashwinvaidya17 marked this conversation as resolved.
Show resolved Hide resolved
if task == "classification" and mask_dir:
raise ValueError(
warnings.warn(
"Classification task is requested, but mask directory is provided. "
"Segmentation task is to be chosen if mask directory is provided."
)
self.task = "segmentation"

ashwinvaidya17 marked this conversation as resolved.
Show resolved Hide resolved
if task is None or mask_dir is None:
self.task = "classification"
else:
Expand Down
2 changes: 1 addition & 1 deletion anomalib/utils/callbacks/visualizer_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def on_test_batch_end(
visualizer = Visualizer(num_rows=1, num_cols=num_cols, figure_size=(12, 3))
visualizer.add_image(image=image, title="Image")

if self.task == "segmentation":
if "mask" in outputs:
true_mask = outputs["mask"][i].cpu().numpy() * 255
visualizer.add_image(image=true_mask, color_map="gray", title="Ground Truth")

Expand Down