TensorFlow image_processing component#17795
Conversation
15b2029 to
dc517b8
Compare
|
@hunterjm great work on this. Couple of comments:
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'ps accidentally pushed commit to address that, meant to create a PR Cheers |
|
Currently the state data will require parsing: { "dog": [ { "score": 99.44924116134644, "box": [ 0.0563804991543293, 0.18027611076831818, 0.6681657433509827, 0.6643975973129272 ] } ], "chair": [ { "score": 96.00539803504944, "box": [ 0.015583686530590057, 0, 0.35551923513412476, 0.29479289054870605 ] } ], "potted plant": [ { "score": 94.95822787284851, "box": [ 0.10585738718509674, 0.5190292596817017, 0.5562731027603149, 0.9891135692596436 ] } ], "bowl": [ { "score": 86.03321313858032, "box": [ 0.43573233485221863, 0.16289281845092773, 0.8424050807952881, 0.7881014943122864 ] } ] }In Facebox I use a little trick to breakout the |
|
With If I use the camera |
|
@robmarkcole - There is a lot here, so I will break it down by section:
Score has the same intent. I have updated the code to reflect and keep standard. If we want to standardize bounding box, we can as well. TensorFlow returns the
I agree, but I think we can do that (potentially together) as a refactor PR instead of making this one larger in scope.
Thanks for the fix. It's a harmless warning, but can see how it could confuse the standard user.
I looked at what you were doing in Facebox, and drew some inspiration from there. This one is a little peculiar since each category could have multiple detections. With Facebox, you are breaking out a known matched face, and there can only be one of those. In this scenario, there can be more than one
Great catch! I forgot to test
You are probably using |
Bounding box@hunterjm I like the convention for bounding box you propose ( Data displayRe displaying the returned data, you currently provide: {'dog': [{'confidence': 99.45,
'bounding_box': [0.0563804991543293,
0.18027611076831818,
0.6681657433509827,
0.6643975973129272]}],
'chair': [{'confidence': 96.01,
'bounding_box': [0.015583686530590057,
0,
0.35551923513412476,
0.29479289054870605]}],What I propose is that in addition to this full info, we provide a summary: {'dog': : 99.45,
'chair': 96.01,This is the approach in Facebox, and makes it easy to see whats been identified from the HA front end: TemplatingRe the templating of the filename, I'm still confused and getting exceptions, what should my config be for the following? The description for the snapshot service I find much clearer, and I have: file_out:
- '/Users/robincole/.homeassistant/images/my_camera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg' |
|
@robmarkcole We should try to be close to Facebox, but it is not a perfect match as there can be more than one object detected. We can add a summary, but I feel that it is redundant. We can use For file_out:
- "/home/homeassistant/.homeassistant/downloads/camera/test_{{ now().strftime('%Y%m%d_%H%M%S') }}.jpg"Although, ideally you would like to include |
|
DEFAULT_CONFIDENCE is already part of the platform :) I think a summary is required, as something like this isn't very helpful |
|
@robmarkcole - I hear you on the summary. I still don't think having |
8bb9cd3 to
5f83b00
Compare
houndci-bot
left a comment
There was a problem hiding this comment.
Some files could not be reviewed due to errors:
Traceback (most recent call last):
Traceback (most recent call last):
File "/home/linters/.local/bin/flake8", line 7, in
from flake8.main.cli import main
ModuleNotFoundError: No module named 'flake8'
houndci-bot
left a comment
There was a problem hiding this comment.
Some files could not be reviewed due to errors:
Traceback (most recent call last):
Traceback (most recent call last):
File "/home/linters/.local/bin/flake8", line 7, in
from flake8.main.cli import main
ModuleNotFoundError: No module named 'flake8'
houndci-bot
left a comment
There was a problem hiding this comment.
Some files could not be reviewed due to errors:
Traceback (most recent call last):
Traceback (most recent call last):
File "/home/linters/.local/bin/flake8", line 7, in
from flake8.main.cli import main
ModuleNotFoundError: No module named 'flake8'
|
@robmarkcole - Updated to show the summary and resolve merge conflicts. What are the next steps here? |
|
@robmarkcole - I did not mean to. It got dropped in the rebase. |
| # See PR #8103 for more info. | ||
| RUN pip3 install --no-cache-dir -r requirements_all.txt && \ | ||
| pip3 install --no-cache-dir mysqlclient psycopg2 uvloop cchardet cython | ||
| pip3 install --no-cache-dir mysqlclient psycopg2 uvloop cchardet cython opencv-python-headless |
There was a problem hiding this comment.
I'm always a bit wary if we need to install things for every single user of Home Assistant. Why can't we install this on demand?
There was a problem hiding this comment.
It looks like it will also work without opencv. We should remove this.
There was a problem hiding this comment.
The thought here was to make it as easy as possible for those using the official docker image. OpenCV is pre-built in the Hass.io images here, though from source. The pip package makes it easier to install.
I was aiming for consistency.
| model_dir = model_config.get(CONF_MODEL_DIR) | ||
|
|
||
| # append custom model path to sys.path | ||
| sys.path.append(model_dir) |
There was a problem hiding this comment.
Ehhhrrrrr
We should be able to specify the paths to look to tensorflow?
There was a problem hiding this comment.
There are some requirements that can not be installed via pip. The object detection portion of the library is not included in the standard TensorFlow wheel. This is to include the protobuf models and util functions created as a part of the tensorflow install shell script.
|
These binaries/tensorflow should really be in a different container if you want to use them. Home Assistant should just contain the glue to interface with it, but not the actual code. |
|
Hi @rv-jhunter, It seems you haven't yet signed a CLA. Please do so here. Once you do that we will be able to review and accept this pull request. Thanks! |
da02698 to
c04a105
Compare
4736c4d to
6005ddd
Compare
…. Update to have tensorflow in root config directory
|
It is great to see this added, well done. But it won't replace my setup for security. Here is what would be awesome:
I have motion + a custom script (PHP) that does that, would love to replace it with home assistant. |
|
Please open an issue if you suspect a bug. If you want to suggest an enhancement please open a feature request in the Feature Requests section of our community forum. Merged PRs should not be used for enhancement discussion or bug reports. If you've found a bug it's ok to make a review with inline comments and link to an issue that reports the bug. Thanks! |

Description:
Adding a TensorFlow Object Detection image_processing component to run either pre-trained or custom built machine learning object detection models through TensorFlow and expose the results to Home Assistant.
Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#7083
Example entry for
configuration.yaml(if applicable):Checklist:
tox. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTSvariable.requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.