This is my backend service that supports image classification using ResNet model (with torch) and FastAPI. This also have task queue management with celery.
docker compose build
docker compose up
If you want to run in your machine instead of run in docker environment, follow the below instructions:
poetry install
Install redis db or run via docker:
docker run --name redis -d --rm -p 6379:6379 redis
poetry run uvicorn --reload "imgnet.main:app"
poetry run celery -A imgnet.worker.celery worker -l DEBUG
poetry run celery -A imgnet.worker.celery flower
wget https://upload.wikimedia.org/wikipedia/commons/7/7d/Labrador_Chocolate.jpg
curl --location 'http://localhost:8000/api/classify' --form 'file=@"./Labrador_Chocolate.jpg"'
# => {"job_id":"1864a0b5-a34e-4c3d-88c2-aa906aeecb71"}
curl http://localhost:8000/api/fetch-job/1864a0b5-a34e-4c3d-88c2-aa906aeecb71
# => {"status":"PENDING","result":null}
# or {"status":"SUCCESS","result":[{"name":"flat-coated retriever","prob":0.3873564600944519},{"name":"Labrador retriever","prob":0.22092069685459137},{"name":"vizsla","prob":0.1640702337026596},{"name":"German short-haired pointer","prob":0.049478743225336075},{"name":"curly-coated retriever","prob":0.04324338585138321}]}
Via localhost:5555