-
Notifications
You must be signed in to change notification settings - Fork 666
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
🚀 Customisable Image Visualizer #2334
🚀 Customisable Image Visualizer #2334
Conversation
This reverts commit 47f183a.
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
…ation methods Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
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.
The new visualizer looks amazing. I have a few minor comments. Also, how do we plan to tackle text-only output of VLM?
def visualize_field( | ||
field: str, | ||
value: torch.Tensor, | ||
*, # Mark the following arguments as keyword-only |
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.
Where is this used?
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 want user to use keywords for the rest of the arguments after *. For example, following line follows this keyword-only format
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.
image = visualize_field(field, value, colormap=colormap, normalize=normalize)
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.
So, basically we want to force the users to pass parameters using keywords
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.
Yes, because such args are hard to read/follow if a keyword is not provided
This is for image-based models. I'll need to implement |
Signed-off-by: Samet Akcay <[email protected]>
…alib into pil-based-visualization
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
@jpcbertoldo, how does it look like now? Both is possible with the updated PR |
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.
Looks fine to me. But not sure if I am completely sold on the field config, and overlay field config part. I usually rely on my IDE to suggest customisable parameters. With the nested dict, it is harder to figure how, and to what I can I change the parameters to.
How often would we see users change these parameters? If it is not very frequent, then I am in favour of being a little more opinionated and keep these parameters as constants. If the users want something else, they can modify the source.
that'd make my life easier :) |
Looks really cool. The design is somehow complete but not complicated as expected haha. I wanted to try something like this visualizer = ImageVisualizer(
fields=["image", "anomaly_map"],
overlay_fields=[("image", ["anomaly_map", "gt_mask"]), ("anomaly_map", ["gt_mask"])],
fields_config={"pred_mask": {"color": (255, 0, 0)}},
overlay_fields_config={
"anomaly_map": {"alpha": 0.6, "mode": "fill"},
"pred_mask": {"alpha": 1., "mode": "contour"},
},
) Will try tomorrow, my environment has some unsaved stuff right now. By the way the output of example 5 is outdated, right? Because the pred mask config is set to |
Signed-off-by: Samet Akcay <[email protected]>
For some reason, |
Really nice feature! from anomalib.visualization.image import ImageVisualizer
visualizer = ImageVisualizer(
overlay_fields=[("image", ["gt_mask"]), ("image", ["anomaly_map", "gt_mask"]), ("anomaly_map", ["gt_mask"])],
overlay_fields_config={
"anomaly_map": {"alpha": 0.5, "mode": "fill"},
"gt_mask": {"alpha": 1., "mode": "contour", "color": (255, 0, 255)},
},
)
engine = Engine(callbacks=[visualizer])
engine.test(datamodule=data, model=model) gives i would suggest gt_mask overlayed as a default, it really helps to compare the images because it gives a reference shape to locate things |
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/design-simplifications #2334 +/- ##
=================================================================
Coverage ? 78.44%
=================================================================
Files ? 288
Lines ? 12367
Branches ? 0
=================================================================
Hits ? 9701
Misses ? 2666
Partials ? 0 ☔ View full report in Codecov by Sentry. |
06daad9
into
openvinotoolkit:feature/design-simplifications
📝 Description
ImageVisualizer
class to Anomalib, providing a flexible and customizable way to visualize anomaly detection results. TheImageVisualizer
can be used as a callback in the Anomalib Engine. The subsequent PRs will add the visualizer to the base model, so users will be able to modify it from there as well.Features
ImageItem
Examples
1: Engine-specific visualizer
When not set, Anomalib will use the default visualizer settings, which would be equivalent to the following
The code above will produce the following output
2: Default visualizer
3: Customized visualizer
It is possible to overlay any custom field on top of each other. This includes multiple fields, which overall makes this design fully customizable.
4: Modifying overlay appearance
5: Advanced configuration combining multiple customizations
✨ Changes
Select what type of change your PR is:
✅ Checklist
Before you submit your pull request, please make sure you have completed the following steps:
For more information about code review checklists, see the Code Review Checklist.