Closed robmarkcole closed 5 years ago
Hi Robin. Added to the /facebox/teach endpoint to the code
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"
}
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?
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
Updated the code and tested with your above code. Seems to work. Would be great if you could test.
@RdeLange teach service working after your updates, great work!
Release v0.4 also added a
teach
service, which has a different endpoint from yourtrain
. I expect the fix is as simple as replacingtrain
with/facebox/teach