Skip to content

Commit

Permalink
Merge pull request #426 from MichaelClifford/v1.1.0_objdetpython
Browse files Browse the repository at this point in the history
Add object detection model server readme
  • Loading branch information
rhatdan authored May 2, 2024
2 parents c05ecc3 + 88102bb commit 1c4b4ed
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
6 changes: 2 additions & 4 deletions model_servers/object_detection_python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ all: build download-model-facebook-detr-resnet-101 run

.PHONY: download-model-facebook-detr-resnet-101
download-model-facebook-detr-resnet-101:
pip install -r ../../convert_models/requirements.txt
cd ../../convert_models/ && \
python3.11 download_huggingface.py -m facebook/detr-resnet-101
cp -r ../../convert_models/converted_models/facebook ../../models/
cd ../../models/ && \
python download_hf_models.py -m facebook/detr-resnet-101

.PHONY: test
test:
Expand Down
52 changes: 52 additions & 0 deletions model_servers/object_detection_python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Object_Detection_Python Model Server

The object_detection_python model server is a simple [FastAPI](https://fastapi.tiangolo.com/) application written specifically for use in the [object_detection recipe](../../recipes/computer_vision/object_detection/) with "DEtection TRansformer" (DETR) models. It relies on huggingface's transformer package for `AutoImageProcessor` and `AutoModelforObjectDetection` to process image data and to make inferences respectively.

Currently, the server only implements a single endpoint, `/detection`, that expects an image in bytes and returns an image with labeled bounding boxes and the probability scores of each bounding box.

## Build Model Server

To build the object_detection_python model server image from this directory:

```bash
podman build -t object_detection_python . base/Containerfile
```
or
```bash
make build
```

## Download Model(s)

You can download models from [huggingface.co](https://huggingface.co/) for this model server. This model server is intended to be used with "DEtection TRansformer" (DETR) models. The default model we've used and validated is [facebook/detr-resnet-101](https://huggingface.co/facebook/detr-resnet-101).

You can download a copy of this model into your `models/` with the make command below.

```bash
make download-model-facebook-detr-resnet-101
```
or any model with

```bash
cd ../../models/ && \
python download_hf_models.py -m <MODEL>
```


## Deploy Model Server

The model server relies on a volume mount to the localhost to access the model files. It also employs environment variables to dictate the model used and where its served. You can start your model server using the following `make` command from the [`model_servers/object_detection_python`](../../../model_servers/object_detection_python) directory, which will be set with reasonable defaults:

```bash
make run
```
or

```bash
podman run -it -d -p 8000:8000 \
-v <LOCAL/PATH/TO/MODLES>/facebook/detr-resnet-101:/models/facebook/detr-resnet-101:ro \
-e MODEL_PATH=/models/facebook/detr-resnet-101 \
-e HOST=0.0.0.0 \
-e PORT=8000 \
ghcr.io/ai-lab/model_servers/object_detection_python:latest
```

0 comments on commit 1c4b4ed

Please sign in to comment.