BirdNET-Analyzer icon indicating copy to clipboard operation
BirdNET-Analyzer copied to clipboard

Docker container for "server.py"

Open mmcc-xx opened this issue 2 years ago • 0 comments

A suggestion...

I'm looking to implement something like BirdNET-Pi but container-ized. For what I have in mind, it would be more useful to have server.py running in a container than analyze.py so that services in other containers can call it with shortish audio files.

I haven't tried it yet but it looks like all that needs to happen is to change "analyze.py" to "server.py", but I don't know the best way to maintain several Dockerfiles in one directory.

Update: I've now tried it and it worked a treat. I replace tensorflow with tflite-runtime for lite-ness.

Dockerfile

# Build from Python 3.8 slim
FROM python:3.8-slim

# Install required packages while keeping the image small
RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg  && rm -rf /var/lib/apt/lists/*

# Install required Python packages
RUN pip3 install numpy scipy librosa bottle resampy

# Install Tensforflow
RUN pip3 install tflite-runtime

# Import all scripts
COPY . ./

# Add entry point to run the script
ENTRYPOINT [ "python3" ]
#CMD [ "analyze.py" ]
CMD [ "server.py" ]

Built image with docker build -t birdnetserver .

Simple docker-compose.yml

version: "2.3"
services:
  birdnetserver:
    restart: unless-stopped
    image: birdnetserver
    ports:
      - 8080:8080

Update - I made more changes to server.py to get the data to output with what BirdNET-Pi needs. Specifically, the time interval associated with detections was missing. I started a repo to house this, as well as changes on the BirdNET-Pi side: https://github.com/mmcc-xx/BirdCAGE

Update 2 - I made another changes to server.py and analyze.py to provide a way for a client to get the species list and likelihood scores given lat, long, week, and sf_thresh values. All of my changes are here. https://github.com/mmcc-xx/BirdCAGE/tree/main/BirdNET-Analyzer. Also my containerizable app is now usable if the specified changes are made to BirdNET-Analyze.

mmcc-xx avatar May 10 '23 15:05 mmcc-xx