diff --git a/Dockerfile b/Dockerfile index 050e94c..77d2be6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,4 +12,4 @@ COPY app /app WORKDIR /app ENTRYPOINT [ "streamlit", "run"] -CMD ["streamlit-ui.py"] \ No newline at end of file +CMD ["deepstack-ui.py"] \ No newline at end of file diff --git a/README.md b/README.md index ac38fec..03a0403 100644 --- a/README.md +++ b/README.md @@ -9,24 +9,28 @@ UI for working with [Deepstack](https://python.deepstack.cc/). Allows uploading Run deepstack object detection: ``` -docker run -e VISION-DETECTION=True -p 5000:5000 -e API-KEY="" -e MODE=High deepquestai/deepstack:cpu-x6-beta +docker run -e VISION-DETECTION=True -p 5000:5000 -e API-KEY="" -e MODE=High deepquestai/deepstack:latest ``` -You will need the ip address of the machine running deepstack, which is passed to the Streamlit app. +You will need the ip address of the machine running deepstack, which is passed to the Streamlit app using an environment variable. -## Run with Docker -From the root dir, build from source then run the UI: +## Run deepstack-ui with Docker +The `deepstack-ui` is designed to be run in a docker container. The UI picks up the information about your deepstack instance from environment variables which are passed into the container using the `-e VARIABLE=value` approach. All environment variables that can be passed are listed below: +``` +- DEEPSTACK_IP : the IP address of your deepstack instance, default "localhost" +- DEEPSTACK_PORT : the PORT of your deepstack instance, default 80 +- DEEPSTACK_API_KEY : the API key of your deepstack instance, if you have set one +- DEEPSTACK_TIMEOUT : the timeout to wait for deepstack, default 10 seconds +``` + +From the root dir, build the deepstack-ui container from source and then run the UI, passing the `DEEPSTACK_IP` environment variable: ``` docker build -t deepstack-ui . docker run -p 8501:8501 -e DEEPSTACK_IP='192.168.1.133' deepstack-ui:latest ``` -The UI is now viewable at [http://localhost:8501](http://localhost:8501) +The UI is now viewable at [http://localhost:8501](http://localhost:8501) (not whatever ip address is shown in the logs, this is the internal docker ip) -Alternatively run the [pre-built](https://hub.docker.com/repository/docker/robmarkcole/deepstack-ui) image in daemon mode: -``` -docker run -p 8501:8501 -e DEEPSTACK_IP='192.168.1.133' -d --name deepstack_ui robmarkcole/deepstack-ui:latest -``` -Or if you are running deepstack with non default parameters, an example would be: +Alternatively if you are running deepstack with non default parameters, an example would be: ``` docker run -p 8501:8501 \ -e DEEPSTACK_IP='192.168.1.133' \ @@ -36,34 +40,6 @@ docker run -p 8501:8501 \ robmarkcole/deepstack-ui:latest` ``` -Then visit [localhost:8501](http://localhost:8501/) (not whatever ip address is shown in the logs, this is the internal docker ip) - -Above examples for using with docker-compose: -``` - deepstack: - container_name: deepstack - restart: unless-stopped - image: deepquestai/deepstack:cpu-x3-beta - ports: - - '5000:5000' - environment: - - VISION-DETECTION=True - - API-KEY="" - volumes: - - /srv/docker/deepstack:/datastore - deepstack_ui: - container_name: deepstack_ui - restart: unless-stopped - image: robmarkcole/deepstack-ui:latest - environment: - - DEEPSTACK_IP=deepstack - - DEEPSTACK_PORT=5000 - - DEEPSTACK_API_KEY="" - - DEEPSTACK_TIMEOUT=20 - ports: - - '8501:8501' -``` - ### FAQ Q1: I get the error: `TypeError: cannot unpack non-iterable DeepstackException object` @@ -74,5 +50,5 @@ A1: You probably didn't pass the required environment variables (`DEEPSTACK_IP` ## Development * Create and activate a venv: `python3 -m venv venv` and `source venv/bin/activate` * Install requirements: `pip3 install -r requirements.txt` -* Export required environment variable: `export DEEPSTACK_IP='192.168.1.133'` -* Run streamlit from `app` folder: `streamlit run streamlit-ui.py` \ No newline at end of file +* Export required environment variables: `export DEEPSTACK_IP='192.168.1.133'` +* Run streamlit from `app` folder: `streamlit run deepstack-ui.py` \ No newline at end of file diff --git a/app/streamlit-ui.py b/app/deepstack-ui.py similarity index 94% rename from app/streamlit-ui.py rename to app/deepstack-ui.py index f4eadf7..a8fecaf 100644 --- a/app/streamlit-ui.py +++ b/app/deepstack-ui.py @@ -11,11 +11,11 @@ import const ## Depstack setup DEEPSTACK_IP = os.getenv("DEEPSTACK_IP", "localhost") -DEEPSTACK_PORT = os.getenv("DEEPSTACK_PORT", 5000) +DEEPSTACK_PORT = os.getenv("DEEPSTACK_PORT", 80) DEEPSTACK_API_KEY = os.getenv("DEEPSTACK_API_KEY", "") -DEEPSTACK_TIMEOUT = int(os.getenv("DEEPSTACK_TIMEOUT", 10)) +DEEPSTACK_TIMEOUT = int(os.getenv("DEEPSTACK_TIMEOUT", 20)) -DEFAULT_CONFIDENCE_THRESHOLD = 0 +DEFAULT_CONFIDENCE_THRESHOLD = 45 # percent TEST_IMAGE = "street.jpg" DEFAULT_ROI_Y_MIN = 0.0 @@ -35,8 +35,7 @@ predictions = None @st.cache def process_image(pil_image, dsobject): image_bytes = utils.pil_image_to_byte_array(pil_image) - dsobject.detect(image_bytes) - predictions = dsobject.predictions + predictions = dsobject.detect(image_bytes) return predictions diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..34d1b7d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,22 @@ +deepstack: +container_name: deepstack +restart: unless-stopped +image: deepquestai/deepstack:latest +ports: + - '5000:5000' +environment: + - VISION-DETECTION=True + - API-KEY="" +volumes: + - /srv/docker/deepstack:/datastore +deepstack_ui: +container_name: deepstack_ui +restart: unless-stopped +image: robmarkcole/deepstack-ui:latest +environment: + - DEEPSTACK_IP=deepstack + - DEEPSTACK_PORT=5000 + - DEEPSTACK_API_KEY="" + - DEEPSTACK_TIMEOUT=20 +ports: + - '8501:8501' \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index faa8536..93dc7af 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ numpy>=1.18.5 Pillow>=7.1.2 -deepstack-python==0.6 -streamlit==0.70.0 \ No newline at end of file +deepstack-python==0.7 +streamlit==0.72.0 \ No newline at end of file