Closed nirmalaagash closed 6 years ago
Have you tested the model in darknet/keras to see if it detects in those environments?
It's pretty hard to debug errors in the processing code in this lib for a model, but one thing you can do is look at the intermediate tensors and see if they're funny values like NaN or 0's
I checked it. it is working fine. It predicted those two classes with >90% prediction.
I'll check through what you mentioned. But have I missed any steps in between?
I guess it's possible that the inputImage isn't in the right format, how are you feeding in the input?
const inputImage = webcam.capture();
passing the image taken directly from the webcam
Have you tried feeding in an image directly? You can do so by instead of targeting a video element, to use an image element when constructing the webcam object. I imagine it's possible that the model is overfitting to images that you're passing in but not recognizing webcam quality images. Alternatively, you can try testing webcam images on your model in darknet/keras.
Otherwise you'll probably have to dig into inspecting the tensors in this lib itself for the culprit, but it can be tricky unless there is obvious 0s/NaNs. Another sanity check might be if the default pretrained model work in your setup or not, there could be some weird tfjs dependency error going on that's happened in the past (but hopefully have fixed by now).
Alternatively, you can try testing webcam images on your model in darknet/keras.
Approached the above said. Model seems to work fine with the webcam images. Maybe I'll try doing the conversion again.
Last time while converting to keras, parameter "buffer" buffer=weights_file.read(filters * 4))
in the convolution function in yad2k.py was giving out the error
TypeError: buffer is too small for requested array when reading file
Hence I removed that parameter and converted it without any error. Could this be the issue?
It's been a while since I had to deal with it, but have you seen this comment? https://github.com/allanzelener/YAD2K/issues/83#issuecomment-364649222
That could definitely be a problem.
It is working now. Thanks @MikeShi42
That's great, could you share the problem/solution for future reference?
I changed weights_file.read(16)) to weights_file.read(20)) in yad2k.py. Previously it was weights_file.read(16)). Then it worked fine.
Hi,
I had trained my yolo-tiny-v2 with my dataset of 2 classes(width and height being 416). Also, converted the final .weights file to keras using YAD2K converter. And then used tensorflowjs converter to convert it to web model which resulted in model.json file along with shard files.
Coming to the code in tfjs-yolo-tiny-demo repo I have successfully passed the uploaded json file url in
model = await downloadModel(url);
Also the options in yolo function -const boxes = await yolo(inputImage, model,{numClasses:2, classNames :['X1','X2']});
Output is empty array.
What changes do I have to make.Please guide me in making my custom detection compatible to yours.