Skip to content

Why is the result different when using TilerConfiguration callback and not using TilerConfiguration callback? #2793

Open
@wenwu2021

Description

@wenwu2021

def predict(a):
transform = Compose([
Resize(size=(256, 256)),

])
dataset = PredictDataset(
    path=r"D:\BaiduNetdiskDownload\Zbar\AnomalibTensorrtAlg\x64\Debug\result\033.png",
    transform=transform,
)
pre_processor = PreProcessor(transform=transform)

# model = Patchcore()
# # prepare tiling configuration callback
model = Patchcore(pre_processor=pre_processor)
print(a)
if a==1:

    tiler_config_callback = TilerConfigurationCallback(enable=True, tile_size=[128, 128], stride=64)
    engine = Engine(callbacks=[tiler_config_callback])
else:
    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)

a=1
tensor([0.3981])

a=2
tensor([0.4398])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions