Skip to content

Feat: Magic Eraser (Generative Inpainting) #696

@Aryan-Shan

Description

@Aryan-Shan

Describe the feature

Description

Currently, users cannot easily remove unwanted objects or people from their photos within PictoPy. They need to use external tools for basic photo editing tasks like object removal, which breaks their workflow and reduces productivity.

Magic Eraser introduces a powerful AI-powered inpainting feature that allows users to seamlessly remove unwanted elements from their photos with just a few brush strokes. This feature uses a lightweight ONNX model to generate realistic backgrounds where objects are removed, providing professional-grade editing capabilities within the app.

Why This Feature?

  1. Adds "Wow" Factor - Generative AI editing impresses users and sets PictoPy apart from basic photo viewers
  2. Complete Workflow - Users can edit photos without leaving the application
  3. Privacy-First - All processing happens locally using ONNX runtime
  4. Premium Feel - Professional editing tools typically found in paid applications

Key Features

  • Interactive Brush Tool: Adjustable brush size for precise selection
  • Real-time Preview: See removal results instantly before saving
  • Undo/Redo Support: Multiple levels of undo for experimentation
  • High-Quality Output: Compositing technique preserves original image quality
  • Seamless Integration: Works alongside existing features like Text Detection

Technical Implementation

  • Backend: FastAPI endpoint with LaMa ONNX model for inpainting
  • Frontend: React component with canvas-based brush interaction
  • Model: Lightweight LaMa model (~50MB) for fast local inference
  • Compatibility: Works with common image formats (JPG, PNG, WebP)

User Workflow

  1. User selects "Magic Eraser" tool
  2. Adjusts brush size and paints over unwanted objects
  3. Clicks "Remove Object" to see AI-generated result
  4. Can undo/redo as needed
  5. Saves edited image to their collection

Tests

  • Verified backend endpoint functionality
  • Tested frontend component integration
  • Ensured cross-browser compatibility

Code Quality

  • Follows project coding standards
  • Proper error handling implemented
  • Performance optimized (async processing)
  • No linting issues (ruff/black compliant)

Integration

  • Works with existing image viewer
  • No conflicts with other features
  • Updated setup scripts for automatic model download
  • Added to requirements.txt

User Experience

  • Intuitive UI with tooltips
  • Responsive design for different screen sizes
  • Clear feedback during processing
  • Preserves original image quality

Record

I agree to follow this project's Code of Conduct

Technical Notes

  • Uses numpy<2.0 for ONNX Runtime compatibility
  • Model automatically downloads during setup via scripts/download_models.py
  • Implements intelligent compositing to preserve image quality
  • Processes images asynchronously to prevent UI blocking
Image Image

Add ScreenShots

Adds advanced image editing feature to the app.

Record

  • I agree to follow this project's Code of Conduct
  • I want to work on this issue

Checklist before Submitting.

  • Have you updated docs for it?.
  • Have you added unit tests?.
  • Have you made sure unit tests pass?
  • Have you made sure code formatting is correct?
  • Does it contain any style related issues?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions