ModelDepot / tfjs-yolo-tiny

In-Browser Object Detection using Tiny YOLO on Tensorflow.js
https://modeldepot.io/mikeshi/tiny-yolo-in-javascript
MIT License
530 stars 92 forks source link

no-compile version #4

Closed hpssjellis closed 6 years ago

hpssjellis commented 6 years ago

Awesome work Mike.

I have taken all the Tensorflowjs examples and made them into pure javascript no-compile versions, but I am having some issues with yours.

Any suggestions? I use these script tags

  <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.9.0"> </script> 
  <script src="https://cdn.jsdelivr.net/npm/tfjs-yolo-tiny"> </script> 

I am confused about how the converted tensorflow model gets loaded onto the page.

My site and non-working demo are at https://github.com/hpssjellis/beginner-tensorflowjs-examples-in-javascript/tree/master/tf-examples/tfjs-yolo-tiny

P.S. If you don't like me using your work I will take it off my site.

MikeShi42 commented 6 years ago

What I'm suspecting is the issue is that it expects to be able to require in @tensorflow/tfjs as a dependency (it's a peer dependency for this package). This is because I ran into issues where Tensorflow only expects one instance of it running at any time, so if you have tfjs dependent on your main project, and try to use tfjs-yolo-tiny, it'll say that tfjs is already instantiated and stop working.

I believe it's possible to fix this via specifying that it can pull tfjs as a global via this line: https://github.com/ModelDepot/tfjs-yolo-tiny/blob/master/webpack.config.js#L28. But I'm not 100% sure. Let me know if you'd be interested in picking up this issue/submitting a PR :)

Edit:

Oh and of course I'm more than happy to see our work being shared :)

hpssjellis commented 6 years ago

I got it partially working It is making inferences but not showing the bounding boxes. Shows no error, so I am going to have to dig a bit deeper. If I can get that working I will look into some of the memory leaks that were tweeted.

MikeShi42 commented 6 years ago

If I were to guess, it’s because the bounding boxes are drawn using divs (I know... but forgive me for my time constraints), and since the stylesheet isn’t being found, they’re most likely not being rendered properly on top of the video element.

hpssjellis commented 6 years ago

I agree. I started from scratch again and now my minimalist non-build tools version works. This is really nice code. I will spend some time today trying to understand it.

Great work making this.