qqwweee / keras-yolo3

A Keras implementation of YOLOv3 (Tensorflow backend)
MIT License
7.14k stars 3.45k forks source link

Trained models not working on tensorflowjs #595

Open PranoySarkar opened 4 years ago

PranoySarkar commented 4 years ago

After training a model, and converting the model to tfjs, if I try to use the model in TFJS getting this error.

Error loading layer ValueError: Unknown layer: Lambda. This may be due to one of the following reasons:

  1. The layer is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
  2. The custom layer is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().

Is there any chance to fix this?

PranoySarkar commented 4 years ago

by adding a empty lambda layer you can suppress this error check here , but while predicting getting this error "Error: Error when checking model : the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see 4 Tensor(s), but instead got 1 Tensors(s).

check this https://stackoverflow.com/questions/59233377/alternative-for-lambda-layer-in-yolo3-keras/

reedts commented 4 years ago

I second this. Would also be interested in a possible solution.

stanleyyylau commented 4 years ago

by adding a empty lambda layer you can suppress this error check here , but while predicting getting this error "Error: Error when checking model : the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see 4 Tensor(s), but instead got 1 Tensors(s).

check this https://stackoverflow.com/questions/59233377/alternative-for-lambda-layer-in-yolo3-keras/

I want to use to tfjs too, have you fixed this issue?

PranoySarkar commented 4 years ago

by adding a empty lambda layer you can suppress this error check here , but while predicting getting this error "Error: Error when checking model : the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see 4 Tensor(s), but instead got 1 Tensors(s). check this https://stackoverflow.com/questions/59233377/alternative-for-lambda-layer-in-yolo3-keras/

I want to use to tfjs too, have you fixed this issue?

Try this with Tf 1.4 https://github.com/Tony607/object_detection_demo

stanleyyylau commented 4 years ago

by adding a empty lambda layer you can suppress this error check here , but while predicting getting this error "Error: Error when checking model : the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see 4 Tensor(s), but instead got 1 Tensors(s). check this https://stackoverflow.com/questions/59233377/alternative-for-lambda-layer-in-yolo3-keras/

I want to use to tfjs too, have you fixed this issue?

Try this with Tf 1.4 https://github.com/Tony607/object_detection_demo

Thanks a lot, I will take a detailed look, one quick question, the link you posted seem to be using TensorFlow's object detection API, what's the difference between yolov3 and the object detection API. which one would you recommend for objection detection on client-side using TensorFlow.js?

PranoySarkar commented 4 years ago

I also don't know much, (if anyone reading this & if I am wrong please correct) YOLO, SSD, F-RCNN these are the algorithms to train the model, the repository I have given there it will be using SSD , if you open the colabfile you will be able to see, I struggled a lot for a long time this is the only solution that worked if used tensorflow 1.14 , if you are using colab just add this in the beginning !pip install tensorflow==1.14.0 it will work

stanleyyylau commented 4 years ago

I also don't know much, (if anyone reading this & if I am wrong please correct) YOLO, SSD, F-RCNN these are the algorithms to train the model, the repository I have given there it will be using SSD , if you open the colabfile you will be able to see, I struggled a lot for a long time this is the only solution that worked if used tensorflow 1.14 , if you are using colab just add this in the beginning !pip install tensorflow==1.14.0 it will work

Thanks for your help. this also for for tfjs right?

PranoySarkar commented 4 years ago

I also don't know much, (if anyone reading this & if I am wrong please correct) YOLO, SSD, F-RCNN these are the algorithms to train the model, the repository I have given there it will be using SSD , if you open the colabfile you will be able to see, I struggled a lot for a long time this is the only solution that worked if used tensorflow 1.14 , if you are using colab just add this in the beginning !pip install tensorflow==1.14.0 it will work

Thanks for your help. this also for for tfjs right?

yes!

FahriBilici commented 3 years ago

@PranoySarkar i have same problem. did you solved?