Skip to content

How to set a threshold at inference time? #578

Answered by ashwinvaidya17
alevangel asked this question in Q&A
Discussion options

You must be logged in to vote

@alevangel The thresholds are overwritten when on_predict_start is called from LoadModelCallback. One idea would be to manually call torch.load and pop LoadModelCallback from the callbacks list. Then updating the thresholds will work. This solution might work for your use case for now but we will try to come up with a better design.

Here is a snippet of the change to the infer function of lightning_inference.py

def infer():
    """Run inference."""
    args = get_args()
    config = get_configurable_parameters(config_path=args.config)
    # This is commented as setting this adds LoadModelCallback to the callback list
    # config.trainer.resume_from_checkpoint = str(args.weights)
    config.

Replies: 8 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by djdameln
Comment options

You must be logged in to vote
1 reply
@ashwinvaidya17
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #554 on September 23, 2022 11:51.