Giter Club home page Giter Club logo

tfclassify-unity-barracuda's Introduction

What

This is an example of using models trained with TensorFlow or ONNX in Unity application for image classification and object detection. It uses Barracuda inference engine - please note that Barracuda is still in development preview and changes frequently.

More details in my blogpost.

Classify results:

Detect results:

If you're looking for similar example but using TensorflowSharp plugin instead of Barracuda, see my previous repo.

How

You'll need Unity 2019.3 or above. Versions 2019.2.x seem to have a bug with WebCamTexture and Vulkan that causes memory leak.

  • Open the project in Unity.
  • Install Barracuda 0.4.0-preview plugin from Window -> Package Maanger (the sample didn't work with 0.5.0-preview last time I checked it).
  • In Edit -> Player Settings -> Other settings make sure that you have Vulkan in Graphics APIs for Android or Metal for iOS (remove Auto Graphics API check if neccessary). Barracuda is also suppose to work with OpenGLES3 + ES3.1, but I didn't have any luck with it.
  • Open Classify or Detect scene in Assets folder.
  • Make sure that Classifier or Detector object has Model file and Labels file set.
  • in File -> Build settings choose one of the scenes and hit Build and run.

For iOS, you might need to fix team settings and privacy request message for camera in Xcode.

Barracuda repository might be found here.

How to use your own model

There are limited range of neural network architectures that I managed to get to run with Barracuda. Read my blogpost to see what's working and what isn't.

Notes

I'm not a Unity expert, so if you found any problems with this example feel free to open an issue.

tfclassify-unity-barracuda's People

Contributors

syn-mcj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tfclassify-unity-barracuda's Issues

barracuda not success to convert the pb file

I am downing the ml-agents file from the github link you provide,and use anaconda prompt to cd to the destination of converter.py,and type the code ,python tensorflow_to_barracuda.py my.pb destination the output destination,And it cames out that there is no mlagents module.
I donot know why

Input shape Mismatch when converting another keras model to onnx

Hi,
First of all great project, reall useful. I am trying to do face detection specifically instead of object detection, so I need an onnx tiny yolo model trained for this task. I was able to find a pre-trained keras model so its extension is h5. I saw that you converted tiny yolo model to onnx with the tool called OnnxMLTools. I am using keras2onnx but the input's shape turns out to be (1, 416, 3, 416) instead of (1, 416, 416, 3) and I believe this creates a problem. Can you please explain how to use OnnxMLTools because I wasn't able to figure out how to use it after reading the readme file?

Working on a YOLO-Barracuda implementation

Hi, I just wanted to ask if you have made any attempts to run Barracuda inference engine on a custom render texture as I can see that in your work you have incorporated the use webcam texture(api).

But I am planning to run yolo on Barracuda using Render Texture instead, can I ask if its possible using your work and could you point me in the right direction if possible.

Thanks a lot!

Combining object detection with AR

Hi,

I am trying to use this for object detection. I want to combine this with AR. For example, on detecting a object DOG, instead of drawing a bounding box, I want to show a animation in that area. I don't have good knowledge on Unity as I am using it for the first time. Is it possible? If yes, can you point to any references that would be helpful

Not working on Android

The project seems to work in my laptop but when I compile the apk and try to run it in my Android smartphone (Xiaomi Redmi Note 7), it inmediately crushes. Here I present a screenshot of the app when I point at my laptop. The image randomly crops and duplicates and everything start to shake. Why might this be happening? Thank you.
WhatsApp Image 2020-04-20 at 11 27 53

Covert a cyclegan model to barracuda

Hi, I have been trying to deploy a cyclegan model into unity with Barracuda, but I have failed many times. I have tried different methods and other pretrained models from Internet. Usually the errors like missing layers(I am not sure if this will affect the usage of the model, I have one converted successfully to nn with missing layers, but failed when run on Android), -1 not supported by lamda... I am actually having no experiences in neural network, so I am kind of struggling now. Any suggestions? I have tried tensorflowsharp too, I cannot even compile it with ARcore. Are there any other plugins that I should shoot for?

tensorflow model to Barracuda or Onnx

I would like to know if it would be possible to get a Teachable Machine model into Unity and use it with Barracuda Currently I have tried to convert a Tensorflow model with tensorflow_to_barracuda.py which I get this error: google.protobuf.message.DecodeError: Error parsing message

I have also tried to convert the model with the tf2onnxt but when I have successfully convert the model and import it the model has warnings

also when I import any model of my own the camera is responding every second

-Unity version 2020.1
-Barracuda version have tried with 0.4.0 and 0.6.3

Hope Teachable Machine models is possible to use since it's fast and easy for the project i am working on

App crashes after few seconds.

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?

Yolo Output grid (1,13,13,30) instead of (-1,-1,-1,-1)

Hey @Syn-McJ,
I'm just looking for some advice regarding my model. I tried making my own yolov2-tiny model (on 1 class) to deploy on Unity. I am not an expert on YOLO models. The output grid shape is different than your description on the website, also it is different from the graph you have in your repository. I was wondering how you did the calculations based on the graph you had to be able to get results. I looked at the microsoft website to get more familiar with their procedures, however, calculations done in Unity is a bit different.
As of now, the result I am getting for confidence or results is NaN which is most likely due to miscalculations. My whole model is different, but it works when I use darknet detector source code with an image.
Do you have any idea or resources that can help me?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.