Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model is not giving correct prediction scores after conversion #5523

Open
nahla-naz opened this issue Jun 20, 2024 · 0 comments
Open

Model is not giving correct prediction scores after conversion #5523

nahla-naz opened this issue Jun 20, 2024 · 0 comments

Comments

@nahla-naz
Copy link

nahla-naz commented Jun 20, 2024

Hi,

I created a Pytorch model which is giving >80% accuracy on windows. The prediction scores are within the range of 0 and 1. However, after I convert it to NCNN, it is giving 0 and 1 as scores. I managed to solve this problem by adding a softmax layer:
out = F.softmax(out, dim=1)
Now, the prediction scores are between 0 and 1. But the accuracy is very low.

How can I make the accuracy of NCNN model same as that of Pytorch model?

I converted the model from .pth to .onnx using below method and converted .onnx to .param and .bin using convertmodel.com(without simplifying or optimising).

model=torch.load('model.pth',map_location=torch.device('cpu'))
model.eval()
input_tensor = torch.randn(1, 3, 80, 80 )
exportModel = model
torch.onnx.export(exportModel, input_tensor, 'path' +
('modelNEW.onnx'), export_params=True, input_names=["data"], output_names=["softmax"])

Kindly help. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant