Closed alejones closed 8 months ago
Thanks for the good report and pre-investigation. :+1:
I was able to reproduce the problem locally with this Dockerfile. I'll look deeper into it and get back to you here.
Great, please let me know if there is anything I can do to help!
Ok, to avoid the reported error, one can do data_in = data_in[0]
in convert_model.py
.
However, the output of the model is not a tensor (or a list of tensors), but a dictionary:
{
'boxes': array([[[-1., -1., -1., -1.], ... [-1., -1., -1., -1.]]], dtype=float32),
'confidence': array([[-1., ...., -1.]], dtype=float32),
'classes': array([[-1, ..., -1]]),
'num_detections': array([0], dtype=int32)
}
This is a problem for the 'outputs': list(map(show_tensor, as_list(data_out_test)))
part in convert_model.py
, which leads to another error. So far, frugally-deep just does not support this.
The thing is, this Yolo model is not a "plain" model (type tensorflow.keras.models.Model
), but something else (wtype keras_cv.src.models.object_detection.yolo_v8.yolo_v8_detector.YOLOV8Detector
) with additional functionality. The backbone model initially might have been a normal Keras model, but so far I have not succeeded in extracting it from the Yolo model to test converting it in isolation.
But even if this would work, using it then with frugally-deep would probably require re-implementing some of the wrapper functionality around it in C++. I don't know if that would be a feasible solution for you.
Thanks for looking into this so quickly! It looks like we may need to use TensorFlow.
If you want to working on this, here is a reference to the backbone in the Keras repo. https://keras.io/api/keras_cv/models/backbones/yolo_v8/
It looks like we may need to use TensorFlow.
Yeah, seems so. :white_check_mark:
Thanks for helping me make this library more user-friendly though by having reported this! :+1:
To avoid others from running into the same problem, i.e., letting them know about the model-type requirement early on, I just added an assertion: https://github.com/Dobiasd/frugally-deep/pull/414
I have a model that I'd like to use, but I'm getting some errors while trying to convert to the Frugally Deep json format.
I've put together a gist with all the code you need to reproduce the error. https://colab.research.google.com/gist/alejones/9fb3098df21ed67822263bd3b478cbe4/object_detection_keras_cv.ipynb
I've made one change to convert_model.py on line 891 to allow it to compile
This brings me to this error
Do you have any suggestions on what I should do to get it the yolo model working with Frugally Deep?