diff --git a/anomalib/deploy/inferencers/torch.py b/anomalib/deploy/inferencers/torch.py index 62c5c3fb76..eb6efc1f46 100644 --- a/anomalib/deploy/inferencers/torch.py +++ b/anomalib/deploy/inferencers/torch.py @@ -138,8 +138,16 @@ def post_process( anomaly_map = predictions pred_score = anomaly_map.reshape(-1).max() else: - anomaly_map, pred_score = predictions - pred_score = pred_score.detach().cpu().numpy() + # NOTE: Patchcore `forward`` returns heatmap and score. + # We need to add the following check to ensure the variables + # are properly assigned. Without this check, the code + # throws an error regarding type mismatch torch vs np. + if isinstance(predictions[1], (Tensor)): + anomaly_map, pred_score = predictions + pred_score = pred_score.detach() + else: + anomaly_map, pred_score = predictions + pred_score = pred_score.detach().numpy() anomaly_map = anomaly_map.squeeze() diff --git a/anomalib/models/cflow/README.md b/anomalib/models/cflow/README.md index e213ff7258..3e8fe2e242 100644 --- a/anomalib/models/cflow/README.md +++ b/anomalib/models/cflow/README.md @@ -47,4 +47,3 @@ All results gathered with seed `42`. ![Sample Result 2](../../../docs/source/images/cflow/results/1.png "Sample Result 2") ![Sample Result 3](../../../docs/source/images/cflow/results/2.png "Sample Result 3") -