Skip to content

Commit

Permalink
Fix Mix Data type issue on inferencer (#77)
Browse files Browse the repository at this point in the history
* Convert the data types

* Black

* added note to the change
  • Loading branch information
samet-akcay committed Jan 27, 2022
1 parent 785feb2 commit dc978c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 10 additions & 2 deletions anomalib/deploy/inferencers/torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
1 change: 0 additions & 1 deletion anomalib/models/cflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit dc978c0

Please sign in to comment.