Runs a Flask API using YOLO to detect objects in a frame. Use Docker to deploy where possible.
Notice these lines of code in api.py
USER_DATA = {
os.environ['DETECT_API_USERNAME']: os.environ['DETECT_API_PASSWORD']
}
You need to set DETECT_API_USERNAME
and DETECT_API_PASSWORD
that matches your streaming client. You can add as many "users" as you would like.
Additionally, rename example.env
to .env
after filling out the contents.
- Images - https://hub.docker.com/r/doorman/yoloapi/
sudo docker run --name redis-yolo -d redis
sudo docker run -d --link redis-yolo:redis -e REDIS_URL=redis://redis:6379/0 --volume "/home/pi/doorman/yolo-detection-api:/src/app" -p 5001:5001 doorman/yoloapi:rpi
(replacerpi
with the version you need from the available Docker images)
- Download the model folder from here and put it the current directory (where this file lives).
sudo docker-compose up --build -d
or for GPUsudo docker-compose -f gpu-compose.yml up --build -d
- Navigate to http://localhost:5001
- Download the model folder from here and put it the current directory (where this file lives).
- Create a virtual environment with Python 3.6
- Run
pip install -r requirements.txt
- Install darkflow
- Run
redis-server
or set theREDIS_URL
environmental variable with the Redis connection string. - (Optional) Set the
THROTTLE_SECONDS
environment variable to limit request calls to this server. The default will be 5 if not set. Use an integer. - Run
python api.py
- Navigate to http://localhost:5001
- darkflow
- OpenCV 3
- Python 3.6
- Tensorflow
- Redis
- Flask