Skip to content
Permalink
Browse files

Fix: Set classes in tflite engine.

Wrong classes makes service fail to send MQTT result.

Signed-off-by: Bofu Chen (bafu) <bofu@dt42.io>
  • Loading branch information...
bafu committed May 9, 2019
1 parent 7403496 commit f59fa06cfb1634500400c6cf5f5a4a3b83297607
Showing with 69 additions and 2 deletions.
  1. +1 −0 berrynet/engine/tflite_engine.py
  2. +2 −2 berrynet/service/tflite_service.py
  3. +66 −0 config/dashboard-tflitedetector.json
@@ -19,6 +19,7 @@ def __init__(self, model, labels):
"""
# Load labels
self.labels = self._load_label(labels)
self.classes = len(self.labels)

# Define lite graph and Load Tensorflow Lite model into memory
self.interpreter = tf.contrib.lite.Interpreter(
@@ -60,8 +60,8 @@ def inference(self, pl):
logger.debug('Result: {}'.format(model_outputs))
logger.debug('Detection takes {} ms'.format(duration(t)))

classes = len(self.engine.labels_map)
labels = self.engine.labels_map
classes = self.engine.classes
labels = self.engine.labels

logger.debug('draw = {}'.format(self.draw))
if self.draw is False:
@@ -0,0 +1,66 @@
{
"version": 1,
"allow_edit": true,
"plugins": [],
"panes": [
{
"title": "Camera Snapshot",
"width": 1,
"row": {
"2": 1,
"3": 1,
"4": 1
},
"col": {
"2": 2,
"3": 1,
"4": 3
},
"col_width": "1",
"widgets": [
{
"type": "html",
"settings": {
"html": "imgstr = datasources[\"Detector Result\"][\"berrynet/engine/tflitedetector/result\"][\"bytes\"]\ns = \"<img src=\\\"data:image/jpeg;base64,\" + imgstr + \"\\\" width=100% height=100%>\"\nreturn s\n\n",
"height": 4
}
}
]
},
{
"title": "Inference Result",
"width": 1,
"row": {
"2": 1,
"3": 1
},
"col": {
"2": 1,
"3": 2
},
"col_width": 1,
"widgets": [
{
"type": "html",
"settings": {
"html": "s = datasources[\"Detector Result\"][\"berrynet/engine/tflitedetector/result\"][\"annotations\"].map(function(r) { \n return (r[\"label\"] + \": \" + r[\"confidence\"] + \"<br />\")\n}).join().replace(/,/g, \"\")\nconsole.log(s)\nreturn s",
"height": 4
}
}
]
}
],
"datasources": [
{
"name": "Detector Result",
"type": "paho_mqtt_js",
"settings": {
"server": "localhost",
"port": 3000,
"client_id": "freeboard_darknetres",
"topics": "berrynet/engine/tflitedetector/result"
}
}
],
"columns": 3
}

0 comments on commit f59fa06

Please sign in to comment.
You can’t perform that action at this time.