ZoneMinder / mlapi

An easy to use/extend object recognition API you can locally install. Python+Flask. Also works with ZMES!
Other
58 stars 35 forks source link

RFE: crop and save (unknown) faces #5

Closed plysdyret closed 4 years ago

plysdyret commented 4 years ago

Hi

I miss a feature to crop and save faces which can then be fed into the known faces structure.

Mvh.

Torkil

pliablepixels commented 4 years ago

This would be useful, but one would need to figure out how to make this happen easily from a "UX" perspective. mlapi/ES are both backend servers with no UI per se, so when an unknown face is detected, how do we "ask" the user who this is?

plysdyret commented 4 years ago

I suggest ignoring the UX part for now and just dump the crops the same way the boxed images are saved. Users can then look at the crop dir in the file system and copy relevant faces to the known faces directory.

Very useful and only a few lines of code needed 🙂

Mvh.

Torkil

pliablepixels commented 4 years ago

please give it a whirl See config.ini for unknown_face related changes

plysdyret commented 4 years ago

Great!

Pulled and enabled. For some reason persons are detected almost always but face detections are few and far between so it might take a bit before I can give any feedback.

plysdyret commented 4 years ago

192.168.40.138 - - [01/Feb/2020 08:34:48] "POST /api/v1/detect/object?type=face&delete=True HTTP/1.1" 500 - Error on request: Traceback (most recent call last): File "/usr/local/lib64/python3.6/site-packages/werkzeug/serving.py", line 304, in run_wsgi execute(self.server.app) File "/usr/local/lib64/python3.6/site-packages/werkzeug/serving.py", line 292, in execute application_iter = app(environ, start_response) File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2463, in __call__ return self.wsgi_app(environ, start_response) File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2449, in wsgi_app response = self.handle_exception(e) File "/usr/local/lib/python3.6/site-packages/flask_restful/__init__.py", line 269, in error_router return original_handler(e) File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1866, in handle_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 38, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python3.6/site-packages/flask_restful/__init__.py", line 269, in error_router return original_handler(e) File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 38, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/usr/local/lib/python3.6/site-packages/flask_restful/__init__.py", line 458, in wrapper resp = resource(*args, **kwargs) File "/usr/local/lib/python3.6/site-packages/flask/views.py", line 89, in view return self.dispatch_request(*args, **kwargs) File "/usr/local/lib/python3.6/site-packages/flask_restful/__init__.py", line 573, in dispatch_request resp = meth(*args, **kwargs) File "/usr/local/lib/python3.6/site-packages/flask_jwt_extended/view_decorators.py", line 108, in wrapper return fn(*args, **kwargs) File "/root/mlapi/api.py", line 125, in post detections = m.detect(image) File "/root/mlapi/modules/face_recognition.py", line 77, in detect closest_distances = self.knn.kneighbors(face_encodings, n_neighbors=1) AttributeError: 'NoneType' object has no attribute 'kneighbors'

plysdyret commented 4 years ago

I also have a bunch of buggy events in zoneminder since updating mlapi. They seem to be registered just fine, just no video. Seems related due to timing.

Mvh.

Torkil

plysdyret commented 4 years ago

Saving unknown faces seems to work like a charm though =)

Mvh.

pliablepixels commented 4 years ago

Please update all components (mlapi+ES+detection) and let me know if you still see this error

plysdyret commented 4 years ago

Thanks, updated. Looking good so far =)

plysdyret commented 4 years ago

There's this though:

" Install Hook [y/N]:y * Installing Hooks ** Checking for YoloV3 data files.... yolov3.cfg exists, no need to download yolov3_classes.txt exists, no need to download yolov3.weights exists, no need to download

Checking for TinyYOLO data files... yolov3-tiny.cfg exists, no need to download yolov3-tiny.txt exists, no need to download yolov3-tiny.weights exists, no need to download sudo: pip3: command not found ERROR:python hooks setup failed "

I know you don't like rookie questions but I can't see the problem. Pip3 is on my path.

pliablepixels commented 4 years ago

Maybe pip3 is not installed globally and when you do sudo it’s not found?

plysdyret commented 4 years ago

I seriously dislike python packaging. You were right, so I just removed the sudo part from the install script and it ran. Thanks!

plysdyret commented 4 years ago

Haven't seen the error with the new version.