-
Notifications
You must be signed in to change notification settings - Fork 43
Running a prediction server with Ark
Jacob Silterra edited this page May 15, 2024
·
4 revisions
A quick way to get started is to use our published Docker container. This container runs a simple web server to receive and process images, and return predictions. See Ark for more information.
If desired, one can run Ark outside of a container. We strongly recommend using an isolated Python environment, using conda or the built-in venv.
The environment must have:
- Python 3.8
- git
One could create an isolated conda environment with:
conda create -n sybil python=3.8 pip
conda activate sybil
# As of this writing, v1.2.0 is the latest tag.
# See https://github.com/reginabarzilaygroup/Sybil/tags for the latest tags
pip install --no-cache-dir --disable-pip-version-check \
--find-links https://download.pytorch.org/whl/cu117/torch_stable.html git+https://github.com/reginabarzilaygroup/[email protected]
# Optionally download the Sybil repository
# git clone https://github.com/reginabarzilaygroup/Sybil
# Verify that the sybil python package has been installed, and download published models
python -c "from sybil import Sybil; model = Sybil('sybil_ensemble')"
# Install ark
git clone https://github.com/reginabarzilaygroup/ark
cd ark
# As of this writing, v0.5.1 is the latest tag.
# See https://github.com/reginabarzilaygroup/ark/tags for the latest tags
git checkout v0.5.1
pip install -r requirements.txt
To launch the ark server with no backing model:
python main.py
This can't be used for prediction but it will verify the software has been installed. One can check that it's running with:
curl http://localhost:5000/info
# Option 1: Serve with Flask (suitable for testing)
ARK_CONFIG=api/configs/sybil.json python main.py
# Option 2: Serve with gunicorn (better for a production environment)
# ARK_CONFIG=api/configs/sybil.json gunicorn --threads 4 --bind 0.0.0.0:5000 --timeout 0 --access-logfile - "main:create_app()"
Now the server is running on the machine. For sample data and a test prediction, we follow the same steps as in the docker-based instructions:
# Check server is running, get version
curl http://localhost:5000/info
# Download and unzip zip file with scripts
curl -L -o ark_predict.zip "https://github.com/reginabarzilaygroup/ark/files/14299465/ark_predict.zip"
tar -xf ark_predict.zip
# Download example data
curl -L -o sybil_example.zip "https://www.dropbox.com/scl/fi/covbvo6f547kak4em3cjd/sybil_example.zip?rlkey=7a13nhlc9uwga9x7pmtk1cf1c&dl=1"
tar -xf sybil_example.zip
# Submit images for prediction
# Mac/Linx
./ark_predict.sh sybil_demo_data