EfficientNet-PyTorch
EfficientNet-PyTorch copied to clipboard
Test with single image gives different result in each runtime
Hi all,
I pretrained myself using EfficientNet B0 with 5 classes, and..
Now I have been loaded using below code:
model = EfficientNet.from_pretrained('efficientnet-b0', weight_path = './weights_path/model.pt', num_classess=5) and i'm using model.eval(), and with torch.no_grad() also.
In a single test phase, i tried two times inference using below code:
outputs = model(inputs) print(outputs) outputs = model(inputs) print(outputs) both outputs printing gives same result but,
If i run again, it gives different result.
Maybe i'm missing something in weight loading part but I couldn't get guess easily.
Please help me, regards.
running on cpu and gpu also gives same situation..
It seems like, setting seeds give same result for each time, but i'm trying to use same input (single image) so.. it's not understandable..
@gihunsong Even I am facing the same issue.
@gihunsong you can try :
model = EfficientNet.from_name('efficientnet-b0', num_classes=5) model.load_state_dict(weights_path)
@gihunsong you can try :
model = EfficientNet.from_name('efficientnet-b0', num_classes=5) model.load_state_dict(weights_path)
@rkakash59 do you mean that you solved the problem that i mentiond using your suggestion?
@gihunsong that was a suggestion.
I missed model.eval() during inference so l was getting inconsistent results. Now I am getting consistent results.
@gihunsong that was a suggestion.
I missed model.eval() during inference so l was getting inconsistent results. Now I am getting consistent results.
@rkakash59 Thanks for your reply.
Could you share your a .py file that you have been using model.eval() part? It'll be helpful for me..
Because I am also using model.eval() in inference but it gives different result every time when i load model and do inference.
@rkakash59 I'm still struggling in this issue.
you suggested the below code: model = EfficientNet.from_name('efficientnet-b0', num_classes=5) model.load_state_dict(weights_path)
could you share your code more in detail upper part of your suggested code?
So weird that no one can explain this issue. My code worked normally with 2 classes but It had problem with 5 classes