nelson1425 / EfficientAD

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

how to inference #7

Closed syha2994 closed 1 year ago

syha2994 commented 1 year ago

hello. thanks for the nice code

How do I just infer an image?

kywish commented 1 year ago

U can refer to the test function in efficientad.py

JHC521PJJ commented 1 year ago
    map_combined, map_st, map_ae = predict(input_img, teacher_model, student_model, 
                                           ae_model, teacher_mean, teacher_std,
                                           q_st_start=q_st_start, q_st_end=q_st_end, 
                                           q_ae_start=q_ae_start, q_ae_end=q_ae_end)

    map_combined = torch.nn.functional.pad(map_combined, (4, 4, 4, 4))
    map_combined = torch.nn.functional.interpolate(
    map_combined, (orig_height, orig_width), mode='bilinear')
    map_combined = map_combined[0, 0].cpu().detach().numpy()
    ad_score = np.max(map_combined)

the ad_score is your need.