nelson1425 / EfficientAD

Unofficial implementation of EfficientAD https://arxiv.org/abs/2303.14535
https://arxiv.org/abs/2303.14535
Apache License 2.0
240 stars 62 forks source link

Get error when evaluate breakfast_box's output with LOCO's official evaluation code #10

Closed cinout closed 1 year ago

cinout commented 1 year ago

Thanks for your great effort in contributing and sharing the reimplementation.

I have a problem here that needs your assistance. After training the MVTec LOCO's breakfast box category, I want to evaluate the output feature maps (in tiff format) using their official evaluation code, but I get this error:

File "[mydrive]/EfficientAD/mvtec_loco_ad_evaluation/src/aggregation.py", line 57, in binary_refinement
    assert len(set(init_queries)) == len(init_queries)

I debugged the issue, and found this error is caused by the fact that the output feature maps contain too many 0 values, such that when the evaluation code creates the initial_thresholds, a.k.a. init_queries (a list of 50 anomaly scores), it contains duplicate values 0. An example is like:

[2.83783058984375, 0.3397859036922455, 0.11129003018140793, 0.04379851371049881, 0.018422557041049004, 0.005928939674049616, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.00046889434452168643, -0.004845781251788139, -0.008791022002696991, -0.012286320328712463, -0.015344921499490738, -0.01806800439953804, -0.02048872597515583, -0.0226922407746315, -0.024705413728952408, -0.026554450392723083, -0.028272513300180435, -0.029879318550229073, -0.0313967764377594, -0.0328390970826149, -0.03421252220869064, -0.0355297289788723, -0.036807697266340256, -0.03804701194167137, -0.03924761712551117, -0.04042193666100502, -0.04157993942499161, -0.04271307215094566, -0.043838512152433395, -0.044960867613554, -0.046086572110652924, -0.04722655192017555, -0.048392221331596375, -0.049606941640377045, -0.05089380219578743, -0.052285678684711456, -0.05385420098900795, -0.055760398507118225, -0.05840958654880524, -0.07654058350419998]

I wonder if anyone encounters the same issue here. I appreciate if you can help me with solving the issue.

cinout commented 1 year ago

Found the issue, it is due to the (4,4,4,4) padding used during upsampling the feature map.

coordxyz commented 1 year ago

Found the issue, it is due to the (4,4,4,4) padding used during upsampling the feature map. @nelson1425 @cinout Have you already solved the problem? And how? Thx~