Skip to content

Commit

Permalink
feat(api): implement object detection, omr, and search routes
Browse files Browse the repository at this point in the history
This commit introduces new API endpoints for object detection, omr, and search functionalities. It replaces the previous implementation with a more robust and efficient solution.  The changes include:

- Implementing object detection using TensorFlow Serving.
- Adding an OMR route for processing Optical Mark Recognition data.
- Implementing a search route using TensorFlow Serving and image cropping.
- Removing old routes and dependencies.
- Adding new utility functions for image processing and data handling.
- Updating project dependencies and configurations.
- Improving code structure and organization.
- Adding support for Docker and Docker Compose.

These changes enhance the API's capabilities and provide a better user experience.  They also improve maintainability and scalability.
  • Loading branch information
shba007 committed Dec 21, 2024
1 parent 5a788d6 commit 8d69c93
Show file tree
Hide file tree
Showing 35 changed files with 1,226 additions and 2,397 deletions.
18 changes: 17 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Git/Github
.git
.github
.gitignore

# FastAPI dev/build outputs
__pycache__
.ruff_cache
Expand All @@ -16,4 +21,15 @@ logs

# Env files
.env*
!.env.example
!.env.example

# Dockerfile
.dockerignore
Dockerfile

# Assets files
assets
!assets/**/.gitkeep
models

firebase-cred.json
8 changes: 1 addition & 7 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
FIREBASE_CONFIG=
STORAGE_BUCKET=
QDRANT_URL=
QDRANT_SECRET=
MEILISEARCH_URL=
MEILISEARCH_SECRET=
NITRO_PRESET=
NITRO_CORS_URL=
NITRO_API_URL=
TENSORFLOW_API_URL=
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ logs
.env*
!.env.example

# Assets files
assets/*
!assets/**/.gitkeep
models

firebase-cred.json
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ ARG VERSION
ARG BUILD_TIME

ENV PYTHON_ENV=production

ENV PATH="/app/.venv/bin:$PATH"

COPY --from=builder /app /app
COPY --from=builder /app/.venv /app/.venv
COPY --from=builder /app/assets /app/assets
COPY --from=builder /app/server /app/server

WORKDIR /app

Expand Down
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'unai'
services:
api:
build: .
env_file:
- .env.prod
ports:
- 2300:8000

tf-serve:
image: "tensorflow/serving:2.18.0"
ports:
- 1510:8500
- 1511:8501
volumes:
- type: bind
source: models
target: /models
tty: true
command: --model_config_file=/models/models.config
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"fastapi[standard]>=0.115.6",
"meilisearch>=0.33.0",
"pillow>=11.0.0",
"tensorflow-cpu>=2.18.0",
"weaviate-client>=3.26.7,<4.0.0",
"firebase-admin>=6.6.0",
"httpx>=0.28.1",
"numpy>=2.0.2",
"opencv-contrib-python-headless>=4.10.0.84",
"pillow>=11.0.0",
"pydantic-settings>=2.7.0",
"pydantic>=2.10.4",
"scipy>=1.14.1",
"nanoid>=2.0.0",
]

[dependency-groups]
Expand All @@ -29,5 +28,6 @@ dev = [
dev = "fastapi dev server/main.py"
lint = "ruff check --fix"
format = "ruff format"
preview = "fastapi run server/main.py"
docker-build = "docker build --build-arg VERSION_TAG=dev -t unai-api-fastapi:dev ."
docker-start = "docker run --detach --name unai-api-fastapi-dev --env-file .env.prod -p 2300:8000 unai-api-fastapi:dev"
8 changes: 8 additions & 0 deletions server/core/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from pydantic_settings import BaseSettings


class Config(BaseSettings):
tensorflow_api_url: str = ""


config = Config()
6 changes: 3 additions & 3 deletions server/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from fastapi import FastAPI

# from .dependencies import get_query_token
from .routers import health, detect, search

# from server.dependencies import get_query_token
from server.routes import health, detect, omr, search

app = FastAPI() # dependencies=[Depends(get_query_token)])

app.include_router(health.router)
app.include_router(detect.router)
app.include_router(search.router)
app.include_router(omr.router)
83 changes: 0 additions & 83 deletions server/routers/detect.py

This file was deleted.

65 changes: 0 additions & 65 deletions server/routers/scan.py

This file was deleted.

Loading

0 comments on commit 8d69c93

Please sign in to comment.