Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 🛠 Bug fix in the inferencer #475

Merged
merged 1 commit into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion anomalib/deploy/inferencers/torch_inferencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def post_process(self, predictions: Tensor, meta_data: Optional[Union[Dict, Dict
meta_data = self.meta_data

if isinstance(predictions, Tensor):
anomaly_map = predictions.cpu().numpy()
anomaly_map = predictions.detach().cpu().numpy()
pred_score = anomaly_map.reshape(-1).max()
else:
# NOTE: Patchcore `forward`` returns heatmap and score.
Expand Down
2 changes: 1 addition & 1 deletion anomalib/post_processing/normalization/min_max.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def normalize(
) -> Union[np.ndarray, Tensor]:
"""Apply min-max normalization and shift the values such that the threshold value is centered at 0.5."""
normalized = ((targets - threshold) / (max_val - min_val)) + 0.5
if isinstance(targets, (np.ndarray, np.float32)):
if isinstance(targets, (np.ndarray, np.float32, np.float64)):
normalized = np.minimum(normalized, 1)
normalized = np.maximum(normalized, 0)
elif isinstance(targets, Tensor):
Expand Down