Skip to content

Commit

Permalink
Fixed DSR (openvinotoolkit#1486)
Browse files Browse the repository at this point in the history
* fixed DSR squeeze bug

* added comment
  • Loading branch information
phcarval authored and Ashwin Vaidya committed Jan 23, 2024
1 parent ee1f659 commit b8bd3f9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/anomalib/models/dsr/torch_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ def forward(self, batch: Tensor, anomaly_map_to_generate: Tensor | None = None)
).detach()
image_score = torch.amax(out_mask_averaged, dim=(2, 3)).squeeze()

# prevent crash when image_score is a single value (batch size of 1)
if image_score.size() == torch.Size([]):
image_score = image_score.unsqueeze(0)

out_mask_cv = out_mask_sm_up[:, 1, :, :]

outputs = {"anomaly_map": out_mask_cv, "pred_score": image_score}
Expand Down

0 comments on commit b8bd3f9

Please sign in to comment.