From b3f93d40d5b8e6ed656452f11fda2708276af920 Mon Sep 17 00:00:00 2001 From: RohanExploit <178623867+RohanExploit@users.noreply.github.com> Date: Sun, 22 Feb 2026 13:53:28 +0000 Subject: [PATCH 1/2] feat(backend): optimize detection endpoints with image processing pipeline - Update `detect_traffic_sign_endpoint` and `detect_abandoned_vehicle_endpoint` to use `process_uploaded_image`. - This ensures images are validated, resized to max 1024x1024 (reducing CLIP payload size), and stripped of EXIF data. - Improves performance (memory, bandwidth) and security. - `process_uploaded_image` handles exceptions and raises `HTTPException` appropriately. --- backend/routers/detection.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/backend/routers/detection.py b/backend/routers/detection.py index fd88a4f5..a8b9dbfa 100644 --- a/backend/routers/detection.py +++ b/backend/routers/detection.py @@ -406,11 +406,8 @@ async def detect_graffiti_endpoint(image: UploadFile = File(...)): @router.post("/api/detect-traffic-sign") async def detect_traffic_sign_endpoint(request: Request, image: UploadFile = File(...)): - try: - image_bytes = await image.read() - except Exception as e: - logger.error(f"Invalid image file: {e}", exc_info=True) - raise HTTPException(status_code=400, detail="Invalid image file") + # Optimized Image Processing: Validation + Optimization + _, image_bytes = await process_uploaded_image(image) try: client = get_http_client(request) @@ -423,11 +420,8 @@ async def detect_traffic_sign_endpoint(request: Request, image: UploadFile = Fil @router.post("/api/detect-abandoned-vehicle") async def detect_abandoned_vehicle_endpoint(request: Request, image: UploadFile = File(...)): - try: - image_bytes = await image.read() - except Exception as e: - logger.error(f"Invalid image file: {e}", exc_info=True) - raise HTTPException(status_code=400, detail="Invalid image file") + # Optimized Image Processing: Validation + Optimization + _, image_bytes = await process_uploaded_image(image) try: client = get_http_client(request) From dcb7d4e1aa253e808fbc5ec1e26a3146abf1d12d Mon Sep 17 00:00:00 2001 From: RohanExploit <178623867+RohanExploit@users.noreply.github.com> Date: Sun, 22 Feb 2026 14:01:39 +0000 Subject: [PATCH 2/2] fix(render): use render-build.sh as build command and set PYTHONPATH to . - Change `buildCommand` in `render.yaml` from `pip install ...` to `./render-build.sh` to ensure frontend build runs. - Update `PYTHONPATH` from `backend` to `.` to fix import issues in `start-backend.py` and `backend.main`. - This ensures both backend and frontend are built correctly during deployment. --- render.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/render.yaml b/render.yaml index 593ec813..3d620164 100644 --- a/render.yaml +++ b/render.yaml @@ -3,7 +3,7 @@ services: - type: web name: vishwaguru-backend runtime: python - buildCommand: "pip install -r backend/requirements-render.txt" + buildCommand: "./render-build.sh" startCommand: "python start-backend.py" envVars: - key: PYTHON_VERSION @@ -14,7 +14,7 @@ services: name: vishwaguru-backend property: port - key: PYTHONPATH - value: backend + value: . # Required API Keys (must be set in Render dashboard) - key: GEMINI_API_KEY sync: false