nelson1425/EfficientAD

how to inference

Closed this issue · 2 comments

hello. thanks for the nice code

How do I just infer an image?

kywish commented

U can refer to the test function in efficientad.py

    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.