RdeLange / robinvision

Face recognition Service
MIT License
17 stars 6 forks source link

Train and teach incompatible #3

Closed robmarkcole closed 5 years ago

robmarkcole commented 5 years ago

Release v0.4 also added a teach service, which has a different endpoint from your train. I expect the fix is as simple as replacing train with /facebox/teach

RdeLange commented 5 years ago

Hi Robin. Added to the /facebox/teach endpoint to the code

robmarkcole commented 5 years ago

I receive error:

2018-07-12 06:32:08 WARNING (SyncWorker_11) [homeassistant.components.image_processing.facebox] facebox teaching of file /Users/robincole/.homeassistant/images/superman_1.jpeg failed with message:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>Name for the face was not given!</p>

For service data:

{
  "entity_id": "image_processing.facebox_local_file",
  "name": "superman",
  "file_path": "/Users/robincole/.homeassistant/images/superman_1.jpeg"
}
RdeLange commented 5 years ago

mmmm, interesting. When I test with curl -X POST -F "file=@Ronald3.jpg" http://localhost:8080/facebox/teach?name=Ronald things are working. Doe you know how your code would translate in a curl statement?

robmarkcole commented 5 years ago

To convert curl to python checkout https://curl.trillworks.com/ My curl for facebox is:

curl -H 'Content-Type: application/json' -d '{"url":"https://machinebox.io/samples/faces/john.jpg","name":"John Lennon","id":"john.jpg"}' http://localhost:8080/facebox/teach

With corresponding python:

with open(file_path, 'rb') as open_file:
            response = requests.post(
                url,
                auth=requests.auth.HTTPBasicAuth(username, password),
                data={ATTR_NAME: name, 'id': file_path},
                files={'file': open_file})

So I am using the data field whereas you are using params, although I'm not sure that should matter but I'm no expert

RdeLange commented 5 years ago

Updated the code and tested with your above code. Seems to work. Would be great if you could test.

robmarkcole commented 5 years ago

@RdeLange teach service working after your updates, great work!