Skip to content

⚡ Bolt: Optimize detection endpoints image processing#447

Open
RohanExploit wants to merge 2 commits intomainfrom
bolt-detection-image-optimization-2108958505448114795
Open

⚡ Bolt: Optimize detection endpoints image processing#447
RohanExploit wants to merge 2 commits intomainfrom
bolt-detection-image-optimization-2108958505448114795

Conversation

@RohanExploit
Copy link
Owner

@RohanExploit RohanExploit commented Feb 22, 2026

⚡ Bolt: Optimized traffic sign and abandoned vehicle detection endpoints.

💡 What: Replaced raw image.read() with process_uploaded_image(image).
🎯 Why: Raw reads allowed massive files (limited only by server defaults) to be loaded into memory and sent to CLIP API, and exposed EXIF data.
📊 Impact:

  • Reduced memory usage for large uploads.
  • Reduced bandwidth to HF API by resizing images to 1024px.
  • Improved security by stripping EXIF data.
    🔬 Measurement: Verified with a test that process_uploaded_image is now called for these endpoints (test deleted to avoid side effects).

PR created automatically by Jules for task 2108958505448114795 started by @RohanExploit


Summary by cubic

Optimized traffic sign and abandoned vehicle detection by using process_uploaded_image for validation, 1024px resize, and EXIF stripping. Also updated Render deployment to build via render-build.sh and set PYTHONPATH to . to fix imports and ensure the frontend builds.

  • Refactors

    • Replaced image.read() with process_uploaded_image in /api/detect-traffic-sign and /api/detect-abandoned-vehicle.
    • Centralizes validation, 1024x resize, EXIF stripping, and HTTPException handling before calling the model API.
  • Dependencies

    • render.yaml: use ./render-build.sh for build; set PYTHONPATH to . to resolve imports and include frontend build during deploy.

Written for commit dcb7d4e. Summary will update on new commits.

Summary by CodeRabbit

  • Refactor
    • Improved internal code organization by consolidating image processing logic across detection endpoints to use a centralized validation routine. This enhances maintainability and consistency in error handling across the system.

…eline

- 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.
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings February 22, 2026 13:53
@netlify
Copy link

netlify bot commented Feb 22, 2026

Deploy Preview for fixmybharat canceled.

Name Link
🔨 Latest commit dcb7d4e
🔍 Latest deploy log https://app.netlify.com/projects/fixmybharat/deploys/699b0c46c6db0d000883fab9

@github-actions
Copy link

🙏 Thank you for your contribution, @RohanExploit!

PR Details:

Quality Checklist:
Please ensure your PR meets the following criteria:

  • Code follows the project's style guidelines
  • Self-review of code completed
  • Code is commented where necessary
  • Documentation updated (if applicable)
  • No new warnings generated
  • Tests added/updated (if applicable)
  • All tests passing locally
  • No breaking changes to existing functionality

Review Process:

  1. Automated checks will run on your code
  2. A maintainer will review your changes
  3. Address any requested changes promptly
  4. Once approved, your PR will be merged! 🎉

Note: The maintainers will monitor code quality and ensure the overall project flow isn't broken.

@coderabbitai
Copy link

coderabbitai bot commented Feb 22, 2026

📝 Walkthrough

Walkthrough

This pull request refactors image handling in two detection endpoints by replacing local image reading logic with calls to a centralized process_uploaded_image() utility function, shifting error handling responsibility from per-endpoint try/except blocks to the shared processing utility.

Changes

Cohort / File(s) Summary
Image Handling Refactoring
backend/routers/detection.py
Replaced per-endpoint image reading in detect_traffic_sign_endpoint and detect_abandoned_vehicle_endpoint with calls to process_uploaded_image(image). Error handling and validation now delegated to centralized utility rather than local try/except blocks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • PR #327: Modifies the process_uploaded_image utility's image verification and resizing behavior, directly affecting the centralized function now called by these endpoints.
  • PR #330: Introduced the detect_traffic_sign and detect_abandoned_vehicle endpoints that are being refactored in this PR.
  • PR #357: Applies similar image handling refactoring pattern to other endpoints in backend/routers/detection.py.

Suggested labels

size/xs

Poem

🐰 A rabbit hops through tangled code,
Finding duplication down the road,
With centralized utilities so neat,
Two endpoints now share the same treat,
Error handling's delegated with care! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: optimizing detection endpoints' image processing by replacing raw image reading with a centralized utility.
Description check ✅ Passed PR description is comprehensive and well-structured, covering what was changed, why it was changed, and the impact.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bolt-detection-image-optimization-2108958505448114795

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes the detect_traffic_sign_endpoint and detect_abandoned_vehicle_endpoint by replacing raw image.read() with the process_uploaded_image() utility. This brings these two endpoints in line with the optimization pattern already used by other CLIP-based detection endpoints in the file.

Changes:

  • Replaced manual error-prone image reading with process_uploaded_image() in traffic sign detection endpoint
  • Replaced manual error-prone image reading with process_uploaded_image() in abandoned vehicle detection endpoint

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants