Skip to content

Commit

Permalink
Add yolo integration test.
Browse files Browse the repository at this point in the history
  • Loading branch information
anarkiwi committed Oct 12, 2023
1 parent c3d8351 commit d270f3e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jobs:
run: |
cd docker
docker build -f Dockerfile.torchserve . -t iqtlabs/gamutrf-torchserve:latest
cd ..
./tests/test_torchserve.sh
test-gamutrf-extra-images:
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile.cuda-torchserve
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ RUN pip config set global.no-cache-dir false && \
cd serve && \
python3 ./ts_scripts/install_dependencies.py --cuda cu118 --environment prod && \
pip3 install . && \
pip3 install -r examples/object_detector/yolo/yolov8/requirements.txt && \
cd .. && \
rm -rf serve
RUN /usr/local/bin/torchserve --help
Expand Down
19 changes: 1 addition & 18 deletions docker/Dockerfile.torchserve
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,7 @@ RUN pip config set global.no-cache-dir false && \
cd serve && \
python3 ./ts_scripts/install_dependencies.py --environment prod && \
pip3 install . && \
pip3 install -r examples/object_detector/yolo/yolov8/requirements.txt && \
cd .. && \
rm -rf serve
RUN /usr/local/bin/torchserve --help

## example usage with YOLOv8 (https://github.com/pytorch/serve/tree/v0.8.2/examples/object_detector/yolo/yolov8):

# docker build -f Dockerfile.torchserve . -ts iqtlabs/gamutrf-torchserve
# docker run -ti iqtlabs/gamutrf-torchserve bash
# apt-get update && apt-get install -y curl wget
# pip3 install torch-model-archiver
# cd /tmp
# git clone https://github.com/pytorch/serve -b v0.8.2
# cd serve/examples/object_detector/yolo/yolov8
# pip install -r requirements.txt
# wget https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.pt
# torch-model-archiver --model-name yolov8n --version 1.0 --serialized-file yolov8n.pt --handler custom_handler.py
# mkdir model_store
# mv yolov8n.mar model_store/.
# torchserve --start --model-store model_store --ncs
# curl -X POST "localhost:8081/models?model_name=yolov8n&url=yolov8n.mar&initial_workers=4&batch_size=2"
# curl http://127.0.0.1:8080/predictions/yolov8n -T persons.jpg & curl http://127.0.0.1:8080/predictions/yolov8n -T bus.jpg
18 changes: 18 additions & 0 deletions tests/test_torchserve.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -e
TMPDIR=/tmp
sudo apt-get update && sudo apt-get install -y curl wget
sudo pip3 install torch-model-archiver
cd $TMPDIR
git clone https://github.com/pytorch/serve -b v0.8.2
cd serve/examples/object_detector/yolo/yolov8
# TODO: use gamutRF weights here.
wget https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.pt
torch-model-archiver --force --model-name yolov8n --version 1.0 --serialized-file yolov8n.pt --handler custom_handler.py
rm -rf model_store && mkdir model_store
mv yolov8n.mar model_store/
docker run -v $(pwd)/model_store:/model_store --net host -d iqtlabs/gamutrf-torchserve timeout 60s torchserve --start --model-store /model_store --ncs --foreground
sleep 5
curl -X POST "localhost:8081/models?model_name=yolov8n&url=yolov8n.mar&initial_workers=4&batch_size=2"
curl http://127.0.0.1:8080/predictions/yolov8n -T persons.jpg

0 comments on commit d270f3e

Please sign in to comment.