-
Notifications
You must be signed in to change notification settings - Fork 434
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
Different Result after converting to onnx from TF! #1494
Comments
Hi @dedoogong, after following your instructions, I got an error but not the one you describe. For me the model failed to convert with unsupported ops DivNoNan. We should be able to easily add support for that op and get the model to convert. If you are getting a different error, can you upload your .pb file and tell me the exact tensorflow version you are using? tf2onnx uses tensorflow's optimizer, so maybe it is substituting in different ops in a different version. |
Hi! thank you for trying to solve this issue!
|
I found there are something may make this happen. But there was still accuracy issue. |
Are you able to upload the frozen pb file? That would be easiest. Just upload it to OneDrive/Dropbox/Google Drive and post a share link if possible. |
OK, here is the pb file and converted onnx file. you can see that, for example, in the converted onnx, there are 'conv1/Conv2D' and 'conv1/bn/FusedBatchNormV3' which means those nodes are not fused, so it should have same paremeter values as the original ones in pb, but actually 'conv1/Conv2D' doesn't even though conv1/bn/FusedBatchNormV3 has same values, . |
And here is the another onnx file which is modified (conv1/conv3's w is overwritten by the original ones in the pb files after transposing by
after runs the inference like above in step 5, it shows the much better results even there is still little big gap in accuracy. |
Hi @dedoogong, sorry took me a while to get to this. You are right that the converter was setting the weights incorrectly due to a bug in the transpose optimizer. #1528 should fix the issue. Can you confirm that the fix works for you? You said "there was still accuracy issue." but also it gets "almost same result". Were you able to get a model that works for you? Was the accuracy issue with only some of the outputs or all of them? |
I think the accuracy problem comes from bilinear resize op becasue it takes a feature map which contains a quite big values(around 100~400). I think Tensorflow's bilinear resize and ORT's one are little bit different. |
Just to make sure, did you find that the latest tf2onnx on GitHub solves your issue? Your workaround of resetting the weights should no longer be necessary. |
Describe the bug
![disp_orig](https://user-images.githubusercontent.com/12013568/116841645-c509a880-ac14-11eb-8204-6d38891cb015.jpg)
![disp](https://user-images.githubusercontent.com/12013568/116841646-c5a23f00-ac14-11eb-80c3-780eb96bad26.jpg)
Original TF-ASLFeat running result is as below;
Converted Onnx-ASLFeat running result is as below;
Urgency
If there are particular important use cases blocked by this or strict project-related timelines, please share more information and dates. If there are no hard deadlines, please specify none.
Emergent!
System information
To Reproduce
Describe steps/code to reproduce the behavior. Please upload/link the model you are trying to convert if possible.
clone the TF model repo
git clone https://github.com/lzx551402/aslfeat.git &&
cd ASLFeat/pretrained &&
wget https://research.altizure.com/data/aslfeat_models/aslfeatv2.tar; tar -xvf aslfeatv2.tar
add the following lines in the end of init function in the models/base_model.py to get the frozen graph
the code should look like below;
and insert a line of code into def load_imgs() in image_matching.py right after cv.imread(img_path).
get pb file and convert it to onnx
$python3 image_matching.py --config configs/matching_eval.yaml
$python3 -m tf2onnx.convert --graphdef aslfeatv2.pb --output aslfeatv2.onnx --inputs input:0 --outputs kpts:0,descs:0,scores:0 --opset 11
Run the below onnx inference code to get the visualized result.
The text was updated successfully, but these errors were encountered: