-
Notifications
You must be signed in to change notification settings - Fork 153
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
Large difference in yolov5 inference output between Neuron compiled model vs expected #435
Comments
@josebenitezg, |
Hi @jeffhataws Sometimes, the inf1 instance crash and I have to reboot when I trying to convert te xlarge model I use the same code above
it keeps showing a few dots as if it's still compiling |
Complete log
|
I've the same problem, any updates? |
Same issue here, ultralytics/yolov5#7739 (comment) didn't help. The output classes seem to match, but the other part of the tensor isn't the same at all: jp = jit_model(img_tensor)
np = neuron_fix_model(img_tensor)
jp[0]
tensor([[[5.3412e+00, 4.9883e+00, 1.9919e+01, ..., 1.0614e-02,
6.9510e-02, 2.9334e-01],
[1.1563e+01, 6.0070e+00, 2.5475e+01, ..., 1.2538e-02,
8.1747e-02, 2.6231e-01],
[2.0204e+01, 6.7078e+00, 2.6301e+01, ..., 1.2518e-02,
8.8539e-02, 6.8642e-02],
...,
[5.6400e+02, 6.1444e+02, 1.7986e+02, ..., 1.5812e-01,
2.1855e-01, 9.6946e-01],
[5.9491e+02, 6.0066e+02, 1.1395e+02, ..., 3.8019e-02,
1.0645e-01, 9.6876e-01],
[6.1129e+02, 6.1150e+02, 1.3300e+02, ..., 3.8576e-02,
8.6339e-02, 9.1997e-01]]])
np[0]
tensor([[[0.5859, 0.5625, 0.7031, ..., 0.0107, 0.0708, 0.2969],
[0.4727, 0.6250, 0.7969, ..., 0.0125, 0.0825, 0.2637],
[0.5117, 0.6680, 0.8086, ..., 0.0125, 0.0889, 0.0693],
...,
[0.5586, 0.3496, 0.3477, ..., 0.1582, 0.2178, 0.9688],
[0.5469, 0.1357, 0.2773, ..., 0.0378, 0.1050, 0.9688],
[0.3027, 0.3047, 0.2988, ..., 0.0386, 0.0864, 0.9180]]])
jp[0][..., 4][jp[0][..., 4] > 0.45]
tensor([0.8304, 0.6804, 0.7879, 0.8152, 0.6366, 0.7737, 0.8117, 0.6276, 0.7688])
np[0][..., 4][np[0][..., 4] > 0.45]
tensor([0.8281, 0.6797, 0.7891, 0.8164, 0.6367, 0.7773, 0.8086, 0.6250, 0.7695]) |
In the compiler logs you provided the following error indicates an out-of-memory issue during compilation:
The error code will be given a better message in an upcoming release. For now the recommendation is to compile on a larger instance type.
Is it possible you are using an old version of the yolov5 repository? This mutation fix is only available starting in: https://github.com/ultralytics/yolov5/releases/tag/v6.0 If this is not the issue, do you have an example script similar to ultralytics/yolov5#7739 (comment) that easily allows the issue to be reproduced? |
Indeed, upgrading YOLO to v6.1 fixed the issue. The great thing is that v5.0 models are still compatible with the v6 so didn't have to retrain anything ! Thanks ! 🙏 |
Reopening since there may be unresolved issues. @fishuke Could you clarify which issues you have encountered? |
Hello while i was compiling yolov5s6 i encountered this problem. @RobinFrcd can you provide code snippet for compiling yolo v6.1 |
To make it work, I did this:
# Configure to use inplace flag for Neuron
for m in model.modules():
if hasattr(m, 'inplace'):
m.inplace = False
|
Thanks, I successfully compiled yolov5 for neuron. But i have an error while inferencing.
|
I see you're running Python 3.6 + outdated neuron runtime versions, maybe you could try to upgrade everything first. Other than that, no idea, sorry ! |
I updated the neuron runtime following here. I will update python to 3.7 and will see if it helps. Also packages are updated too. |
We managed to successfully run the project it compiles to output but. It doesnt draw anything. It find objects but it fails to draw where are them. Here is my code:
Here is the console output:
|
My problem solved by following new fresh start as @RobinFrcd said. And fixing the code above by removing this line: |
Hi @fishuke, it’s good to see that you were able to get everything working! I’m going to close this issue now that everything appears to be resolved, but please feel free to open a new issue if any other problems come up. |
Yes. Because the network's outputs are already scaled. No need to scale them anymore. |
Originally posted by @josebenitezg in #253 (comment)
Hi!
I was able to convert the model from yolov5 to neuron with the follow code:
Now that I am trying to test and compare I have the tensors outputs different from yolo as follow:
Neuron Yolov5 Model:
Yolov5:
Inference script:
Is there something wrong when converting the model or running inference? The label and also the acc seems to be same as the expected, but tensors not.
Originally posted by @josebenitezg in #253 (comment)
The text was updated successfully, but these errors were encountered: