VisioCraft README

The project's README from github.com/AhmadHassan-BTed/VisioCraft. As one markdown file: README.md.

VisioCraft AI

VisioCraft AI is an advanced, AI-powered application for object extraction, context-aware background fill, and seamless image composition. It leverages state-of-the-art models for segmentation, detection, and generative inpainting.


Features


Project Architecture

VisioCraft has been refactored into a clean, modular architecture to ensure scalability and maintainability.

VisioCraft/
├── app/
│   ├── domain/           # Core business logic and data interfaces (Models, Interfaces)
│   ├── infrastructure/   # External integrations (Detection, Generation, Inpainting, Segmentation)
│   ├── routes/           # API Endpoints (Auth, Composition, Health, Uploads, etc.)
│   └── services/         # Application workflow and logic managers
├── models/               # Local AI models (e.g., mobile_sam.pt, yolov8n.pt)
├── static/               # Static assets (CSS, JS, background images)
├── templates/            # Frontend HTML templates
├── config.py             # Centralized configuration settings
├── main.py               # Application entry point
├── requirements.txt      # Project dependencies
└── README.md             # Project documentation

(Note: Older monolithic components have been transitioned to the new app/ module system)


Setup Instructions

1. Install Dependencies

Make sure you have Python 3.8+ installed.

# It is recommended to use a virtual environment
python -m venv .venv

# On Windows:
.venv\Scripts\activate
# On Linux/Mac:
source .venv/bin/activate

pip install -r requirements.txt

2. Download Models

Download the necessary AI models for local inference (like Mobile SAM and YOLO).

python download_models.py

3. Configure Environment Variables

You can set up environment variables for API keys to use advanced cloud-based AI generation.

export OPENAI_API_KEY="your_openai_api_key"
export HUGGINGFACE_TOKEN="your_huggingface_token"
export STABILITY_API_KEY="your_stability_api_key"

(Note: For Windows PowerShell, use $env:KEY="value" instead of export)

4. Run the Application

Start the VisioCraft server:

python main.py

Open your modern web browser (Chrome recommended) and navigate to http://localhost:5000.


Usage Workflow

  1. Upload: Start by uploading an image.
  2. Segment & Extract: Use the AI tools to click/drag around the subject to auto-segment it, extracting it with a transparent background.
  3. Inpaint: Remove the object from the background using context-aware fill methods.
  4. Compose: Use the canvas to re-arrange layers, scale, and rotate objects.
  5. Download: Save the final composition instantly.

Inpainting & AI Methods

Method Description Characteristics
Stable Diffusion Cloud/API-based generation ⭐ Best Quality, Highly context-aware
OpenCV Fast, local edge blending Instant speed, Emergency fallback
Mobile SAM Local AI segmentation model Accurate object masking
YOLOv8 Local Object Detection Fast and robust bounding boxes

Security Best Practices

VisioCraft (AhmadHassan-BTed/VisioCraft)

clean-architecture
Searching Database…

What is this?VisioCraft AI is a Python web application for object extraction, context-aware background fill, and image composition using computer vision and generative models like YOLO, SAM, and Stable Diffusion.
Is this a desktop app or something I run as a local web server?It is a local web server you start from Python; you then open the interactive canvas UI in your browser (Chrome recommended) rather than installing a native app.
How do I get it running?Install the Python dependencies, download the required AI models (Mobile SAM, YOLO), optionally set API keys as environment variables, then start the server and open it in your browser.
What do I need before running it — just Python, or GPU and API keys too?You need Python 3.8+; GPU acceleration is optional but speeds up object processing, and API keys (e.g. a Stability API key) are only required if you want cloud-based Stable Diffusion generation instead of local methods.
Does image generation work without any API keys?Yes, you can still extract objects and inpaint backgrounds locally with Mobile SAM, YOLO, and OpenCV without any keys, but the best-quality Stable Diffusion inpainting requires a cloud API key and internet access.
Does the app upload my images anywhere, or keep them local?Uploaded media and model caches are kept local and excluded from version control; images only leave your machine if you choose the cloud-based Stable Diffusion option with your own API key.
What inpainting methods can I choose from?VisioCraft offers Stable Diffusion for high-quality cloud/API-based generation and OpenCV for fast local edge blending as an emergency fallback, alongside Mobile SAM and YOLOv8 for segmentation and detection.
How does the object extraction step work?It auto-segments the subject using Mobile SAM and GrabCut when you click or drag around it, then extracts it onto a transparent background for reuse.
Why was the project refactored into a modular architecture?The codebase moved from older monolithic components into a clean app/ module system specifically to improve scalability and maintainability.
What's the full editing workflow once I upload an image?Upload an image, segment and extract the subject, inpaint the exposed background, compose layers on the canvas by scaling and rotating, then download the final composition.
Size
0.1 MB
Stars
658
Updated
CommitJun 30
Age
5mo
Commits · 90 Days