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

Troubles with implementing own model #15

Closed rachuang22 closed 6 years ago

rachuang22 commented 6 years ago

I am trying to implement my own tiny-yolo model into the tfjs yolo tiny demo and I'm running into some input issues. This is the error I was running into: Error: Size (21125) must match the product of shape 13,13,5,85

Here is the link to the json and shard files: https://raw.githubusercontent.com/rachuang22/example-yolo-js/master/model.json

Do you know what shape this is referring to? Any help would be appreciated. Thanks in advance!

MikeShi42 commented 6 years ago

The shape is the output shape of tiny yolo, are you changing the number of classes being detected?

Could you possibly print a summary, give an overview of what you changed about your model, and possibly post a stack trace for that error (if any) so I can have a better understanding.

Jped commented 6 years ago

Hi Mike, thanks for answering quickly. I am working with @rachuang22 on this project. Anyhow, we did change the amount of classes, we retrained on pascal VOC. Now that you mention that it makes sense that we have to change the classes file; however, whenever I try to update the classes file using your tfjs-yolo-tiny-demo yarn just reinstalls the index.bundle.js. I tried taking out tfjs-yolo-tiny from the package.json and also the yarn.lock, but every time I try to re-serve it somehow makes its way back.... this is probably a yarn quesiton, but do you know any way around that?

Also where exactly should we run a summary command? Should that be done in the index.js of this library?

this is an image of the stack trace image

MikeShi42 commented 6 years ago

Np. Makes sense, the stack trace points you here where you'd have to change num classes. There's no way via the API to do that for now, it'd be pretty trivial to add it though (and a PR would be appreciated!)

You'd also want to change the classes file as well as you mentioned, as the class names would be different... hrm. To have a local fork, you'd want to clone this repo, run yarn link, and then in the demo project, run yarn link "tfjs-yolo-tiny". That way your demo project will now talk to your local tfjs-yolo-tiny. You can now modified your locally cloned tfjs-yolo-tiny as you'd like.

No need to run the summary command as the issue relates to using a different set of classes (Your model should output (13, 13, 5, 26) I believe) where as MSCOCO has 80 classes so it expects (13, 13, 5, 85). To do it though if you're interested is you'd run it after const model = await downloadModel() via model.summary().

rachuang22 commented 6 years ago

Whenever I try to link the local package, it just goes through a loop trying to install tfjs-yolo-tiny, after running yarn serve. Do you have experience with this?

MikeShi42 commented 6 years ago

Hrmmm that shouldn't be happening, it shouldn't try to install anything. What's the terminal output after running yarn link in tfjs-yolo-tiny and yarn link tfjs-yolo-tiny in tfjs-tiny-yolo-demo?

rachuang22 commented 6 years ago

I recloned both the tfj-yolo-tiny and the demo and tried to link the demo and the original again. It links successfully. However, when I run 'yarn serve' in tfjs-tiny-yolo-demo, this warning occurs and continues to repeat:

terminal_error
rachuang22 commented 6 years ago

I was also able to catch this error:

terminal_error_another
MikeShi42 commented 6 years ago

I think everything has been resolved over chat :)