deepstack-ui icon indicating copy to clipboard operation
deepstack-ui copied to clipboard

Cannot connect UI docker container to RPi Deepstack

Open lockyt opened this issue 6 years ago • 4 comments

Hi @robmarkcole - I have recently purchased an NCS2 and installed it as well as Deepstack on a RPI3b+. The Deepstack seems to be working on both port 5000:

sudo deepstack start "VISION-DETECTION=True PORT=5000"

or with port 80:

sudo deepstack start "VISION-DETECTION=True"

and can access the Deepstack activation web page with my browser no problem via either port. I also get notification on the Deepstack RPi console showing the connection from my browser.

However when I setup Deepstack UI as a docker container on my NAS, I cannot for the life of me get the two to talk to each other. I have tried the docker container with the following configurations:

docker run -e DEEPSTACK_IP=192.168.55.219 -e DEEPSTACK_PORT=80 -d --net=host --name deepstack_ui robmarkcole/deepstack-ui:latest

docker run -p 8501:8501 -e DEEPSTACK_IP=192.168.55.219 -d --name deepstack_ui robmarkcole/deepstack-ui:latest

docker run -p 8501:8501 -e DEEPSTACK_IP=192.168.55.219 -e DEEPSTACK_PORT=5000 -d --name deepstack_ui robmarkcole/deepstack-ui:latest

docker run -p 8501:8501 -e DEEPSTACK_IP='192.168.55.219' -d --name deepstack_ui robmarkcole/deepstack-ui:latest

but each time I get the following when I go to the Deepstack UI web console at 192.168.55.200:8501:

DeepstackException: Timeout connecting to Deepstack, current timeout is 10 seconds
Traceback:
File "/usr/local/lib/python3.8/site-packages/streamlit/ScriptRunner.py", line 322, in _run_script
    exec(code, module.__dict__)
File "/app/streamlit-ui.py", line 88, in <module>
    predictions = process_image(pil_image, dsobject)
File "/usr/local/lib/python3.8/site-packages/streamlit/caching.py", line 591, in wrapped_func
    return get_or_create_cached_value()
File "/usr/local/lib/python3.8/site-packages/streamlit/caching.py", line 575, in get_or_create_cached_value
    return_value = func(*args, **kwargs)
File "/app/streamlit-ui.py", line 38, in process_image
    dsobject.detect(image_bytes)
File "/usr/local/lib/python3.8/site-packages/deepstack/core.py", line 124, in detect
    response = post_image(url, image_bytes, self._api_key, self._timeout)
File "/usr/local/lib/python3.8/site-packages/deepstack/core.py", line 89, in post_image
    raise DeepstackException(

If I deliberately leave out the IP address, I get a different error, so I know it is resolving the IP in some way or another. It seems to be related to the port but cannot get it to work. I know Deepstack UI uses port 5000 by default but when I set the Deepstack RPI to port 5000 it makes no difference. I have also tried setting the docker networking to host thinking it was on the docker side but to no avail. Can I presume that if I can access the Deepstack activation page that the rest of the Deepstack core is also using that port?

I haven't tried configuring Home Assistant yet as I would like to get the UI working first, but perhaps that can be the next thing to try. I am also using significant other docker containers for things such as HA, so I don't think there is any problem with the docker itself.

I am sure it is something simple but I can't get it to work. Any advice or assistance would be appreciated.

Thanks.

lockyt avatar Jul 16 '20 22:07 lockyt

Sorry forgot to mention, I also tried setting the DEEPSTACK_TIMEOUT=30 but same problem, just shows Running process_image(...). longer before erroring.

lockyt avatar Jul 16 '20 22:07 lockyt

Just to add to this, have been trying a few things. I decided to run the following localhost command on another terminal windows on the raspberry pi to discount networking problems:

curl -X POST -F image=@/mnt/HAConfig/config/facebox/Locky/locky2.jpg 'http://localhost:5000/v1/vision/detection'

I get the same problem where it just sits there. If I stop the Deepstack on the other terminal window, it immediately throws and error saying curl: (52) Empty reply from server so it seems it isn't locked up.

If I check the nohup.out I see the following over and over in the log:

Usage: kill [options] [...]

Options:
 <pid> [...]            send signal to every <pid> listed
 -<signal>, -s, --signal <signal>
                        specify the <signal> to be sent
 -l, --list=[<signal>]  list all signal names, or convert one to a name
 -L, --table            list all signal names in a nice table

 -h, --help     display this help and exit
 -V, --version  output version information and exit

For more details see kill(1).

While I was attempting to fix, I reinstalled Deepstack using install_deepstack.sh and afterwards it was no longer activated. While it was not activated, it did show messages on the console (essentially mirroring that it was not activated) so it seems there is some communication going on, just not when I put a request to it.

Would I be right in thinking this is not a problem with the UI docker container but with the RPi Deepstack? Can I use the NCS2 with a docker Deepstack instead of using the RPi - can't seem to find reference to anyone else doing it.

Appreciate this may not be your issue but any help would be appreciated.

lockyt avatar Jul 17 '20 02:07 lockyt

I fixed it. Ended up having to re-image my pi with buster desktop and then it all worked fine. I had imaged it originally with full Raspberry Pi OS instead of just desktop. Would have been nice if they have told me that in the first place...

But thanks anyway - apologies for having to read all that and me fixing it myself.

Time to now have some fun!

lockyt avatar Jul 17 '20 06:07 lockyt

Hi @lockyt glad you managed to resolve this issue. Cheers

robmarkcole avatar Jul 17 '20 06:07 robmarkcole