The model serving endpoint depends on the clustering results generated from the clustering algorithm. You can either use the provided clustering results in outputs folder or choose to run the clustering algorithm to generate our own clustering results. Refer to How to run the clustering algorithm section if you want to run the clustering algorithm. Otherwise you can proceed to How to spin up the model serving endpoint section.
- Git clone this repository
git clone https://github.com/AddChew/person-reid.git- Navigate into personreid folder
cd personreid- Download the gallery images zipped file from link and place it in personreid folder. Unzip the zipped file with the command below.
unzip Gallery.zip- Create conda environment
conda create -n personreid-clustering python=3.9 -y
conda activate personreid-clustering
pip install -r clustering_requirements.txt- Run the clustering algorithm, which will produce 2 artifacts in outputs folder (i.e. embeddings.npy, Addison_clusterid.csv)
python src/clustering.py-
Make sure that you are in the project root folder (i.e. personreid)
-
Build docker image
docker build -t personreid .- Run container based on built image
docker run -d --name personreid -p 4000:4000 personreid| Component | Specs |
|---|---|
| Docker | version 26.1.0 build 9714adc |
| Host OS | Linux Ubuntu 20.04.6 LTS |
| CPU | x86_64 Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz |
-
Spin up the model serving endpoint based on the steps in
How to spin up the model serving endpointif you have not done so. -
Follow the instructions in either
Swagger UIorPython Clientto interact with the model serving endpoint.
-
Navigate to http://0.0.0.0:4000/docs
-
To interact with /ping endpoint, click on the GET /ping accordion and then click on the
Try it outbutton on the right side of the accordion. After which, click on theExecutebuttom at the bottom. You should see the following response.
{
"message": "pong"
}- To interact with /infer endpoint, click on the POST /infer accordion and then click on the
Try it outbutton on the right side of the accordion. After which, click onChoose Filebutton at the left to upload your image file for inference. Once done, click onExecutebutton. You should see the following response. The actual cluster number that you get might vary.
{
"cluster": 361
}-
Make sure that you are in the project root folder (i.e. personreid)
-
Create conda environment
conda create -n personreid-client python=3.9 -y
conda activate personreid-client
pip install -r client_requirements.txt- Open src/client.py file. You should see the following code snippet between lines 48 and 51. Set the image path in client.infer to your own image path.
if __name__ == '__main__':
client = PersonReIDClient()
print(client.ping()) # Test /ping
print(client.infer("Gallery/0_1_1000.jpg")) # Set the image path to your own image path, test /infer- Run the script with the following command.
python src/client.pyYou should see the following printed on your terminal console. The actual cluster number that you get might vary.
{'message': 'pong'}
{'cluster': 366}