Open
Description
transform = Compose([
Resize(size=(256, 256)),
])
dataset = PredictDataset(
path=r"D:\BaiduNetdiskDownload\Zbar\AnomalibTensorrtAlg\x64\Debug\result\033.png",
transform=transform,
)
# transform = Compose([
# Resize(size=(256, 256))
# ])
pre_processor = PreProcessor(transform=transform)
# datamodule = MVTecAD(root=r"D:\BaiduNetdiskDownload\Zbar\anomalib-2.0.0\datasets\MVTecAD\tile\test",
# category="good",
# train_batch_size= 1,
# eval_batch_size=1,
# num_workers=0)
# model = Patchcore()
# # prepare tiling configuration callback
model = Patchcore(pre_processor=pre_processor)
# tiler_config_callback = TilerConfigurationCallback(enable=True, tile_size=[128, 128], stride=64)
#
# # pass the tiling configuration callback to the engine
# engine = Engine(callbacks=[tiler_config_callback])
engine = Engine()
# train the model (tiling is seamlessly utilized in the background)
predictions=engine.predict(dataset=dataset,
model=model,
ckpt_path=r"D:\BaiduNetdiskDownload\anomalib\anomalib-2.0.0\results\Patchcore\MVTecAD\tile\v4\weights\lightning\model.ckpt")
# 5. Access the results
if predictions is not None:
for prediction in predictions:
image_path = prediction.image_path
print(image_path)
anomaly_map = prediction.anomaly_map # Pixel-level anomaly heatmap
pred_label = prediction.pred_label # Image-level label (0: normal, 1: anomalous)
pred_score = prediction.pred_score # Image-level anomaly score
print(pred_score)
How did the tiler predict?How is the preprocessing done? Does it involve division by 255?
Metadata
Metadata
Assignees
Labels
No labels