VisioCraft README

项目的 README,来自 github.com/AhmadHassan-BTed/VisioCraft。合并为一个 markdown 文件: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)

正在搜索数据库…

这是什么?VisioCraft AI 是一个 Python 网页应用,利用计算机视觉以及 YOLO、SAM、Stable Diffusion 等生成式模型,实现对象提取、结合上下文的背景填充和图像合成。
这是桌面应用,还是在本地运行的网页服务器?它是一个你用 Python 启动的本地网页服务器。启动后,在浏览器中打开交互式画布界面即可(推荐使用 Chrome),无需安装原生应用。
要怎么让它运行起来?安装 Python 依赖,下载所需的 AI 模型(Mobile SAM、YOLO),可选择将 API 密钥设置为环境变量,然后启动服务器,并在浏览器中打开。
运行前需要准备什么?只要 Python 就行,还是也需要 GPU 和 API 密钥?需要 Python 3.8+。GPU 加速是可选的,但能加快对象处理速度。只有当你想使用基于云端的 Stable Diffusion 生成,而不是本地方式时,才需要 API 密钥(例如 Stability API 密钥)。
不用任何 API 密钥,也能生成图像吗?可以。无需密钥,你仍然可以在本地使用 Mobile SAM、YOLO 和 OpenCV 提取对象并修复背景;但若要获得最高质量的 Stable Diffusion 修复效果,则需要云端 API 密钥并联网。
这个应用会把我的图片上传到别处,还是只保存在本地?上传的媒体文件和模型缓存都保存在本地,并被排除在版本控制之外。只有当你选择基于云端的 Stable Diffusion 选项并使用自己的 API 密钥时,图片才会离开你的电脑。
可以选择哪些修复方法?VisioCraft 提供 Stable Diffusion,用于高质量的云端/API 生成;还提供 OpenCV,用于快速的本地边缘融合,作为应急备用方案。另外,它还提供 Mobile SAM 和 YOLOv8,用于分割和检测。
对象提取步骤是怎么运作的?当你点击或拖动框选主体时,它会使用 Mobile SAM 和 GrabCut 自动分割主体,然后将其提取到透明背景上,方便重复使用。
为什么要把项目重构为模块化架构?代码库已从早期的单体组件迁移到清晰的 app/ 模块体系,目的是提升可扩展性和可维护性。
上传图片后,完整的编辑流程是什么?上传图片,分割并提取主体,修复露出的背景,在画布上通过缩放和旋转合成图层,最后下载最终作品。
大小
0.1 MB
星标
3.9K
更新
提交Jun 30
时长
6个月
提交 · 90 天