snowzach / doods

DOODS - Dedicated Open Object Detection Service
MIT License
303 stars 31 forks source link

Using custom tflite model #35

Closed imranulbari closed 2 years ago

imranulbari commented 3 years ago

Hi Dear, thank you for this excellent add-ons on home assistant. Working great for detecting person.

I wish to use a custom model and try to generate using colab at https://colab.research.google.com/github/tensorflow/tensorflow/blob/master/tensorflow/lite/g3doc/tutorials/model_maker_image_classification.ipynb

Configuration:

- name: tflite2 type: tflite modelFile: /share/doods/p4/model_quant.tflite labelFile: /share/doods/p4/labels.txt

Getting the following error message.

2020-10-07T20:40:15.574Z ERROR detector/detector.go:73 Could not initialize detector tflite2: unsupported input tensor name: input_2 {"package": "detector"}

Could you please give me a guideline, how I can generate and use a custom model? Appreciate your time. Thank you.

snowzach commented 3 years ago

The hardest part about figuring this out is trying to determine what are the inputs and outputs from every model and how to interpret them. I haven't found a good way to figure this out automatically (suggestions welcome). If you start doods with the environment variable LOGGER_LEVEL=debug it will print out some information about the model I can try to glean something from.

jakowenko commented 3 years ago

@imranulbari did you ever find a solution for this? I'm trying to do something similar and make a model with faces of friends/family. I get a similar error when mounting the tflite and class file.

My debug logs look like this.

doods    | 2021-01-13T16:12:42.343Z DEBUG   detector/detector.go:61 Configuring detector    {"package": "detector", "config": {"name":"default","type":"tflite","model_file":"models/new_mobile_model.tflite","label_file":"models/class_labels.txt","num_threads":1,"num_concurrent":1,"hw_accel":false,"timeout":120000000000}}
doods    | 2021-01-13T16:12:42.493Z ERROR   detector/detector.go:74 Could not initialize detector default: unsupported input tensor name: serving_default_input_1:0 {"package": "detector"}
doods    | 2021-01-13T16:12:42.493Z FATAL   detector/detector.go:84 No detectors configured {"package": "detector"}
imranulbari commented 3 years ago

@jakowenko, Unfortunately I don't find the solution yet. Let us know if you could. Thanks

Mark612 commented 3 years ago

I compiled the efficientdetlite 1 model for the edgeTPU. If I run it directly against the USB accelerator, it works fine:

----INFERENCE TIME---- Note: The first inference is slow because it includes loading the model into Edge TPU memory. 1295.69 ms 1069.14 ms 1025.86 ms 1025.15 ms 1050.45 ms -------RESULTS-------- person id: 0 score: 0.8125 bbox: BBox(xmin=560, ymin=397, xmax=759, ymax=1043) backpack id: 26 score: 0.4375 bbox: BBox(xmin=1422, ymin=550, xmax=1787, ymax=974)

However, if I take that same model and try to load it into DOODS, I get the same dreaded error "unsupported input tensor name":

2021-06-11T12:53:13.174-0600 DEBUG detector/detector.go:61 Configuring detector {"package": "detector", "config": {"name":"edgetpu","type":"tflite","model_file":"models/efficientdetlite1_6-11-2021_edgetpu.tflite","label_file":"models/labelmap_efficientdetlite1_6-11-2021_edgetpu.txt","num_threads":1,"num_concurrent":1,"hw_accel":true,"timeout":0}}, 2021-06-11T12:53:13.216-0600 ERROR detector/detector.go:74 Could not initialize detector edgetpu: unsupported input tensor name: serving_default_images:0 {"package": "detector"}

snowzach commented 3 years ago

One of these days I'm going to rewrite DOODS in python because there's just too much crap that needs modified to work with Tensorflow in Go.

ozett commented 2 years ago

is there any solution to "unsupported input tensor name"?

i configured the tflite bird-classifier and run into the same problem on start of doods: Could not initialize detector birdclass: unsupported input tensor name: module/hub_input/images_uint8

input/outputs are specified: https://tfhub.dev/google/lite-model/aiy/vision/classifier/birds_V1/3

is there a way to configure this?

thats configured in the .yaml: image image

snowzach commented 2 years ago

Rewrite complete, try with this one: https://github.com/snowzach/doods2

ozett commented 2 years ago

How to follow up with an incdex- error on doods2? i go with a link from here to the new issue on the bird-model?