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]: Setting the threshold using ManualThreshold seems to have no effect on the output of predict #2229

Open
1 task done
JinYuannn opened this issue Aug 1, 2024 · 3 comments

Comments

@JinYuannn
Copy link

JinYuannn commented Aug 1, 2024

Describe the bug

Setting the threshold using ManualThreshold seems to have no effect on the output of predict.
I set the default_value in ManualThreshold to 0.99 and 0.0001, but the images saved by predict are the same.

Dataset

N/A

Model

Reverse Distillation

Steps to reproduce the behavior

model = ReverseDistillation()

threshold = ManualThreshold(default_value=0.1)

engine = Engine(
        max_epochs=50, 
        limit_train_batches=100, 
        threshold=threshold, 
        check_val_every_n_epoch=2,
        logger=True
    )

engine.predict(
        datamodule=folder_datamodule,
        model=model,
        ckpt_path="my ckpt path" )

OS information

OS information:

  • OS: Windows 11
  • Python version: 3.10.11
  • Anomalib version: 1.2.0.dev0
  • PyTorch version: 2.3.1+cu121
  • CUDA/cuDNN version: 121
  • GPU models and configuration: RTX 4090

Expected behavior

different threshold, different predicted mask

Screenshots

No response

Pip/GitHub

GitHub

What version/branch did you use?

No response

Configuration YAML

None

Logs

None

Code of Conduct

  • I agree to follow this project's Code of Conduct
@alexriedel1
Copy link
Contributor

What do your predictions look like and what do you expect? Is the code above your full code, because the model training (and validation) phase is missing.

@JinYuannn
Copy link
Author

JinYuannn commented Aug 13, 2024

  1. Here is my training code:
model = ReverseDistillation()
    
engine = Engine(
    max_epochs=200, 
    check_val_every_n_epoch=5,
    logger=True
)

 engine.fit(datamodule=folder_datamodule, model=model)
  1. When I finish training the model and call the model using the predict method, no matter what value I change the default_value in ManualThreshold to, the 'Predicted Heat Map' and 'Predicted Mask' drawn by predict method are exactly the same. I believe that modifying the threshold should output different 'Predicted Mask'. For example, if I set the threshold very low, there should be many defects.

@JinYuannn
Copy link
Author

@alexriedel1 Looking forward to your reply, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants