Syn-McJ / TFClassify-Unity-Barracuda

An example of using Tensorflow and ONNX models with Unity Barracuda inference engine for image classification and object detection.
MIT License
124 stars 32 forks source link

App crashes after few seconds. #1

Closed Pouyan97 closed 4 years ago

Pouyan97 commented 4 years ago

I made sure all dependencies are as specified and even changed python dependencies for Barracuda, however, the app crashes after a few seconds of running it. I have Unity 2019.3.2 and Using Barracuda 0.4.0. The errors I am getting are Capture I made sure everything is set correctly in every object as specified in the descriptions. Is there something I am missing?

Syn-McJ commented 4 years ago

Hi @Pouyan97, it's not quite clear what the problem is from this screenshot. Only Unity output matters, could you filter it and post a more detailed log here?

Pouyan97 commented 4 years ago

Thank you for the quick response. I got the unity log file attached. My apologies, it is in text format so no fancy coloring. Also, I was wondering if it could be the first warnings I am getting in the console. However, player and android TV shouldn't be the issue. log.txt

Syn-McJ commented 4 years ago

Hi @Pouyan97, So the app is working 20-30 seconds, and crashes? Seems like a memory problem, could you run the profiler to see if memory is leaking?

Also, what version of Unity you're running? You need 2019.3.x (I think, it's the one where UI was changed), previous versions have problem with WebCamTexture leaking when using Vulkan.

Pouyan97 commented 4 years ago

@Syn-McJ I am using the Unity2019.3.2f1. the application crashes after few seconds so I do not see any results. It only goes through the first frames then starts to crash (Jitters then crashes). I am not certain how to detect where the memory leak is from. I don't think you can gather much from one frame but I can send a snip of the profiler if it can help. I wonder how me having the same settings and versions doesn't allow the application to work on my device. Maybe Barracuda's ExcuteAsync isn't compatible with my device?

Syn-McJ commented 4 years ago

@Pouyan97 Weird, in your log, it appears like the app works for half a minute and successfully disposing textures during that time.

In any case, the problem here might be with Barracuda. To check this for sure, could you update the plugin to 0.6 version (latest one) and check Classify example? Unlike Detect, Classify still shows correct results with a newer Barracuda version. And it is quite a minimal example, so if it doesn't work, the problem is probably with the plugin and you can open an issue in their repo: https://github.com/Unity-Technologies/barracuda-release

Pouyan97 commented 4 years ago

Thank you @Syn-McJ ,

Classify works. Seems to have a bit of a delay in the process but still works. It works with Barracuda 0.4.0, but has lower accuracy with Barracuda 0.6.0 which is strange. Detect doesn't work with either. How come the Barracuda example appears to be more laggy than the TFSharp example?

Syn-McJ commented 4 years ago

@Pouyan97 I think it depends on a device, my G8 definitively shows a better performance with barracuda. Perhaps there are differences in Vulkan support. That reminds me - you should make sure you have Vulkan chosen in the graphics section in project settings.

In any case, we're using preview software and it bound to have issues. If TFSharp example works better for you, you should probably stick with it for the time being.

Pouyan97 commented 4 years ago

@Syn-McJ TFSharp also has its own issues with SSD model but still works smoother than Barracuda for now which is surprising. Thank you for following up with this issue.