openvinotoolkit / anomalib

An anomaly detection library comprising state-of-the-art algorithms and features such as experiment management, hyper-parameter optimization, and edge inference.

Home Page:https://anomalib.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make visualization configurable

jschneider opened this issue · comments

Hey,

we are using this code, which works fine:

dataset = PredictDataset(image_path)
dataloader = DataLoader(dataset, num_workers=15)

model = get_model("Patchcore")

output = engine.predict(
  model=model,
  ckpt_path=model_path,
  dataloaders=[dataloader],
)

The output contains everything I expect, everything is fine.

But:
I have a lot of pictures, I want to analyze - and performance matters:

  • Therefore, it would be great if I was able to load the model only once and use it for multiple images.
  • It would be great to avoid generating the debug picture (containing the heat map, mask etc).

I am sure I am missing a simple way to achieve this. Any help appreciated ;-)

I have had the same problem and did not find a fix. Looking forward to a solution!

it is currently not configurable, but we will enable it in v1.1.0. For now, you could disable these lines to not visualize the outputs

_callbacks.append(
_VisualizationCallback(
visualizers=ImageVisualizer(task=self.task),
save=True,
root=self._cache.args["default_root_dir"] / "images",
),
)

Great! Thanks.

Will it be possible to load the model just once and call "predict" several times?

yes, ideally it should be possible. Let us know if it does not work

I can't find a way to load the model once and reuse the loaded model.
Could you give me a hint? I am quite new in this area, so might be a bit blind here...