robmarkcole / HASS-Deepstack-object

Home Assistant custom component for using Deepstack object detection
https://community.home-assistant.io/t/face-and-person-detection-with-deepstack-local-and-free/92041
MIT License
437 stars 97 forks source link

KeyError: 'predictions' #40

Closed robmarkcole closed 5 years ago

robmarkcole commented 5 years ago

I see the error below when there is a problem with the camera:

Traceback (most recent call last):
  File "/Users/robincole/Documents/GitHub/home-assistant/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/Users/robincole/Documents/GitHub/home-assistant/homeassistant/helpers/entity.py", line 378, in async_device_update
    await self.async_update()
  File "/Users/robincole/Documents/GitHub/home-assistant/homeassistant/components/image_processing/__init__.py", line 132, in async_update
    await self.async_process_image(image.content)
  File "/Users/robincole/anaconda3/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/robincole/.homeassistant/custom_components/deepstack_object/image_processing.py", line 157, in process_image
    predictions_json = response.json()["predictions"]
KeyError: 'predictions'
robmarkcole commented 5 years ago

OK it is not a bad image which causes this issue, a bad image returns:

{'success': True, 'predictions': []}

Raised https://forum.deepstack.cc/t/200-code-but-no-predictions/96

robmarkcole commented 5 years ago

Am now catching zero predictions