Jingkang50 / OpenOOD

Benchmarking Generalized Out-of-Distribution Detection
MIT License
831 stars 106 forks source link

No threshold in config file for ReAct #216

Closed PyJulie closed 8 months ago

PyJulie commented 8 months ago

File "/mnt/sda/julie/projects/OSR/OpenOOD-main/OpenOOD-main/openood/postprocessors/react_postprocessor.py", line 41, in postprocess output = net.forward_threshold(data, self.threshold) AttributeError: 'ReactPostprocessor' object has no attribute 'threshold'

zjysteven commented 8 months ago

Could you include more info, for example what were you running/calling when seeing this error? self.threshold is set in https://github.com/Jingkang50/OpenOOD/blob/63e0c7990221fe4c1141b77df3f20d207af8580b/openood/postprocessors/react_postprocessor.py#L47-L52, which should be automatically taken care of if you use our evaluation pipeline or api.

PyJulie commented 8 months ago

I just followed the provided script and run it. It seems that set_hyperapram did not initially work before postprocess function?

zjysteven commented 8 months ago

Were you running without APS mode? If so, I might know what's the problem.

zjysteven commented 8 months ago

@PyJulie Can you try again with the new commit?

PyJulie commented 8 months ago

Hi, I was truly running in APS mode.

I found that

https://github.com/Jingkang50/OpenOOD/blob/63e0c7990221fe4c1141b77df3f20d207af8580b/openood/evaluation_api/evaluator.py#L118-L157

line 118 postprocessor.setup works before line 157 self.hyperparam_search().

Unfortunately, new commit may not work either since self.activation_log should be pre-defined.

I added it into def postprocess(self, net: nn.Module, data: Any) function,

and the codes ran successfully but I am not sure if I got the expected results.

I will further try to solve this issue and pull a commit.

Thank you!

zjysteven commented 8 months ago

If you were running in APS mode then that's weird because during hyperparameter search the evaluator will call set_hyperparam which in turn sets self.threshold for react. Without APS mode indeed it was a bug that self.threshold was missing.

PyJulie commented 8 months ago

Yep, it is quiet weird since I did not get bugs when I was running other methods with the requirements of APS mode.

But I checked my .yml config and training log, which shos the APS mode is on:

image

PyJulie commented 8 months ago

image