Compare commits
37 Commits
Author | SHA1 | Date |
---|---|---|
|
9a1f5c29b4 | |
|
7bfcf3a2d1 | |
|
14aacea642 | |
|
9776672e3f | |
|
94e8d0109e | |
|
9bf136f14e | |
|
61dba38b15 | |
|
e515d4d667 | |
|
b3c6b1a8b4 | |
|
f57e57ae96 | |
|
840178b1d1 | |
|
6ba72afc3a | |
|
2b508e2b1e | |
|
d05e62ffa4 | |
|
8b219a0b05 | |
|
a655b1e3e3 | |
|
3514360d57 | |
|
19c114c933 | |
|
070a8823b5 | |
|
03d30362b1 | |
|
1f2a2a8785 | |
|
f848a05e82 | |
|
97c0e905d9 | |
|
327b22eaea | |
|
73edc027f2 | |
|
da707b1716 | |
|
3d51064fcb | |
|
82a1a837e6 | |
|
53babc21d5 | |
|
2218620a08 | |
|
0622271f91 | |
|
1cbda87a93 | |
|
eb554837f4 | |
|
e5c0ceded0 | |
|
e6421586c3 | |
|
a52f02d6b5 | |
|
a8c9364351 |
|
@ -0,0 +1,3 @@
|
|||
# These are supported funding model platforms
|
||||
|
||||
github: robmarkcole
|
|
@ -0,0 +1,37 @@
|
|||
name: Docker Image CI
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
main:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
-
|
||||
name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
push: true
|
||||
tags: robmarkcole/deepstack-ui:latest
|
||||
build-args: |
|
||||
arg1=value1
|
||||
arg2=value2
|
||||
-
|
||||
name: Image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
@ -19,4 +19,5 @@ bin-release/
|
|||
|
||||
venv
|
||||
.vscode
|
||||
__pycache__*
|
||||
.idea
|
||||
__pycache__*
|
||||
|
|
13
Dockerfile
13
Dockerfile
|
@ -3,13 +3,12 @@ LABEL maintainer="Robin Cole @robmarkcole"
|
|||
|
||||
EXPOSE 8501
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --upgrade pip
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
RUN mkdir -p /app
|
||||
COPY app /app
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
COPY app /app
|
||||
|
||||
ENTRYPOINT [ "streamlit", "run"]
|
||||
CMD ["deepstack-ui.py"]
|
||||
CMD ["deepstack-ui.py"]
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
FROM ubuntu:20.04
|
||||
LABEL maintainer="Robin Cole @robmarkcole"
|
||||
|
||||
EXPOSE 8501
|
||||
|
||||
WORKDIR /root
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
RUN apt-get update
|
||||
RUN apt-get upgrade -y
|
||||
RUN apt-get install -y apt-utils
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata
|
||||
RUN apt-get install -y build-essential git wget sudo pkg-config curl dbus cmake vim nano python3 python3-pip python3-setuptools libjemalloc-dev libboost-dev libboost-filesystem-dev libboost-system-dev libboost-regex-dev autoconf flex bison libssl-dev llvm-10
|
||||
RUN ln -s /usr/bin/python3 /usr/bin/python
|
||||
RUN ln -s /usr/bin/pip3 /usr/bin/pip
|
||||
RUN pip install --upgrade pip
|
||||
RUN pip install numpy==1.17.3 cython pygments==2.4.1
|
||||
RUN export ARROW_HOME=/usr/local/lib
|
||||
RUN export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
|
||||
|
||||
WORKDIR /root
|
||||
RUN wget --no-check-certificate https://github.com/apache/arrow/archive/apache-arrow-3.0.0.tar.gz
|
||||
RUN tar -xvf apache-arrow-3.0.0.tar.gz
|
||||
RUN mkdir -p /root/arrow-apache-arrow-3.0.0/cpp/build
|
||||
WORKDIR /root/arrow-apache-arrow-3.0.0/cpp/build
|
||||
RUN cmake -DCMAKE_INSTALL_PREFIX=$ARROW_HOME -DCMAKE_INSTALL_LIBDIR=lib -DARROW_WITH_BZ2=ON -DARROW_WITH_ZLIB=ON -DARROW_WITH_ZSTD=ON -DARROW_WITH_LZ4=ON -DARROW_WITH_SNAPPY=ON -DARROW_PARQUET=ON -DARROW_PYTHON=ON -DARROW_BUILD_TESTS=OFF ..
|
||||
RUN make -j4
|
||||
RUN make install
|
||||
WORKDIR /root/arrow-apache-arrow-3.0.0/python
|
||||
RUN python setup.py build_ext --build-type=release --with-parquet
|
||||
RUN python setup.py install
|
||||
|
||||
WORKDIR /root
|
||||
RUN rm -R *
|
||||
COPY requirements.txt .
|
||||
RUN pip install -r requirements.txt
|
||||
RUN apt-get remove -y build-essential wget pkg-config apt-utils cmake vim nano libjemalloc-dev libboost-dev libboost-filesystem-dev libboost-system-dev libboost-regex-dev autoconf flex bison libssl-dev
|
||||
RUN apt-get autoremove -y
|
||||
|
||||
RUN mkdir -p /app
|
||||
COPY app /app
|
||||
WORKDIR /app
|
||||
|
||||
ENTRYPOINT [ "streamlit", "run"]
|
||||
CMD ["deepstack-ui.py"]
|
16
README.md
16
README.md
|
@ -1,5 +1,5 @@
|
|||
# deepstack-ui
|
||||
UI for working with [Deepstack](https://python.deepstack.cc/). Allows uploading an image and performing object detection or face recognition with Deepstack. Also faces can be registered with Deepstack. The effect of various parameters can be explored, including filtering filtering by confidence, the classes of object detected, and spatial filtering using a region of interest (ROI).
|
||||
UI for working with [Deepstack](https://github.com/johnolafenwa/DeepStack). Allows uploading an image and performing object detection or face recognition with Deepstack. Also faces can be registered with Deepstack. The effect of various parameters can be explored, including filtering objects by confidence, type and location in the image.
|
||||
|
||||
<p align="center">
|
||||
<img src="https://github.com/robmarkcole/deepstack-ui/blob/master/usage.png" width="1000">
|
||||
|
@ -7,12 +7,11 @@ UI for working with [Deepstack](https://python.deepstack.cc/). Allows uploading
|
|||
|
||||
## Run deepstack
|
||||
Run deepstack object detection:
|
||||
|
||||
```
|
||||
docker run -e VISION-DETECTION=True -p 5000:5000 -e API-KEY="" -e MODE=High deepquestai/deepstack:latest
|
||||
docker run -e VISION-DETECTION=True -p 80:5000 deepquestai/deepstack:latest
|
||||
```
|
||||
|
||||
You will need the ip address of the machine running deepstack, which is passed to the Streamlit app using an environment variable.
|
||||
You will need the ip address of the machine running deepstack, which in my case is `192.168.1.133`.
|
||||
|
||||
## 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:
|
||||
|
@ -20,13 +19,17 @@ The `deepstack-ui` is designed to be run in a docker container. The UI picks up
|
|||
- 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
|
||||
- DEEPSTACK_TIMEOUT : the timeout to wait for deepstack, default 30 seconds
|
||||
- DEEPSTACK_CUSTOM_MODEL : the name of a custom model, if you wish to use one
|
||||
- DEEPSTACK_UI_DEBUG_MODE : options `True` or `False` (default). Lowers the minimum confidence threshold to 1%
|
||||
```
|
||||
|
||||
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 .
|
||||
OR
|
||||
docker pull robmarkcole/deepstack-ui:latest
|
||||
|
||||
docker run -p 8501:8501 -e DEEPSTACK_IP='192.168.1.133' deepstack-ui
|
||||
```
|
||||
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)
|
||||
|
@ -41,6 +44,9 @@ docker run -p 8501:8501 \
|
|||
deepstack-ui
|
||||
```
|
||||
|
||||
## Docker-compose
|
||||
An example docker-compose file is provided. For run commands see [here](https://docs.docker.com/compose/gettingstarted/#step-8-experiment-with-some-other-commands) but the main one you need is `docker-compose up`.
|
||||
|
||||
### FAQ
|
||||
Q1: I get the error: `TypeError: cannot unpack non-iterable DeepstackException object`
|
||||
|
||||
|
|
|
@ -9,9 +9,21 @@ import deepstack.core as ds
|
|||
import utils
|
||||
import const
|
||||
|
||||
DEFAULT_CONFIDENCE_THRESHOLD = 0.45
|
||||
MIN_CONFIDENCE_THRESHOLD = 0.1
|
||||
## Depstack setup
|
||||
DEEPSTACK_IP = os.getenv("DEEPSTACK_IP", "localhost")
|
||||
DEEPSTACK_PORT = os.getenv("DEEPSTACK_PORT", 80)
|
||||
DEEPSTACK_API_KEY = os.getenv("DEEPSTACK_API_KEY", "")
|
||||
DEEPSTACK_TIMEOUT = int(os.getenv("DEEPSTACK_TIMEOUT", 30))
|
||||
DEEPSTACK_CUSTOM_MODEL = os.getenv("DEEPSTACK_CUSTOM_MODEL", None)
|
||||
DEEPSTACK_UI_DEBUG_MODE = bool(os.getenv("DEEPSTACK_UI_DEBUG_MODE", False))
|
||||
|
||||
if DEEPSTACK_UI_DEBUG_MODE:
|
||||
st.title("IN DEEPSTACK_UI_DEBUG_MODE")
|
||||
MIN_CONFIDENCE_THRESHOLD = 0.01
|
||||
else:
|
||||
MIN_CONFIDENCE_THRESHOLD = 0.1
|
||||
MAX_CONFIDENCE_THRESHOLD = 1.0
|
||||
DEFAULT_CONFIDENCE_THRESHOLD = 0.45
|
||||
OBJECT_TEST_IMAGE = "street.jpg"
|
||||
FACE_TEST_IMAGE = "faces.jpg"
|
||||
FACE = "Face"
|
||||
|
@ -28,12 +40,6 @@ DEFAULT_ROI = (
|
|||
DEFAULT_ROI_X_MAX,
|
||||
)
|
||||
|
||||
## Depstack setup
|
||||
DEEPSTACK_IP = os.getenv("DEEPSTACK_IP", "localhost")
|
||||
DEEPSTACK_PORT = os.getenv("DEEPSTACK_PORT", 80)
|
||||
DEEPSTACK_API_KEY = os.getenv("DEEPSTACK_API_KEY", "")
|
||||
DEEPSTACK_TIMEOUT = int(os.getenv("DEEPSTACK_TIMEOUT", 20))
|
||||
DEEPSTACK_CUSTOM_MODEL = os.getenv("DEEPSTACK_CUSTOM_MODEL", None)
|
||||
|
||||
predictions = None
|
||||
|
||||
|
@ -64,7 +70,7 @@ CONFIDENCE_THRESHOLD = st.sidebar.slider(
|
|||
)
|
||||
|
||||
if deepstack_mode == FACE:
|
||||
st.title("Deepstack Face recogntion")
|
||||
st.title("Deepstack Face recognition")
|
||||
|
||||
img_file_buffer = st.file_uploader("Upload an image", type=["png", "jpg", "jpeg"])
|
||||
## Process image
|
||||
|
@ -249,3 +255,7 @@ elif deepstack_mode == OBJECT:
|
|||
|
||||
st.subheader("All filtered objects")
|
||||
st.write(objects)
|
||||
|
||||
if DEEPSTACK_UI_DEBUG_MODE:
|
||||
st.subheader("All predictions data from Deepstack")
|
||||
st.write(predictions)
|
||||
|
|
|
@ -1,22 +1,26 @@
|
|||
deepstack:
|
||||
container_name: deepstack
|
||||
restart: unless-stopped
|
||||
image: deepquestai/deepstack
|
||||
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
|
||||
environment:
|
||||
- DEEPSTACK_IP=deepstack
|
||||
- DEEPSTACK_PORT=5000
|
||||
- DEEPSTACK_API_KEY=""
|
||||
- DEEPSTACK_TIMEOUT=20
|
||||
ports:
|
||||
- '8501:8501'
|
||||
version: "3.9"
|
||||
services:
|
||||
deepstack:
|
||||
container_name: deepstack
|
||||
restart: unless-stopped
|
||||
image: deepquestai/deepstack
|
||||
ports:
|
||||
- '5000:5000'
|
||||
environment:
|
||||
- VISION-DETECTION=True
|
||||
- API-KEY=""
|
||||
volumes:
|
||||
- /Users/robin/Data/pytorch-models:/modelstore/detection
|
||||
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
|
||||
- DEEPSTACK_CUSTOM_MODEL=fire
|
||||
- DEEPSTACK_UI_DEBUG_MODE=True
|
||||
ports:
|
||||
- '8501:8501'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
numpy>=1.18.5
|
||||
Pillow>=7.1.2
|
||||
deepstack-python==0.8
|
||||
streamlit==0.73.0
|
||||
streamlit
|
Loading…
Reference in New Issue