AI Personal Learning
and practical guidance
CyberKnife Drawing Mirror

PhotoDoodle: AI tool for adding artistic doodles to photos with text commands

General Introduction

PhotoDoodle 是一个开源的图像编辑工具,由 ShowLab 开发,专注于通过人工智能技术实现照片的艺术化编辑。用户只需输入简单的文本提示词,就能为真实照片添加卡通风格、3D效果、光环、翅膀等装饰元素,生成虚实结合的艺术作品。它基于强大的深度学习模型,支持少样本学习,能快速适应用户个性化风格,适合艺术家、设计师或普通用户进行创意创作。项目托管于 GitHub,提供代码、数据集和预训练模型,方便开发者复现或二次开发。其独特的“照片涂鸦”功能填补了传统编辑软件的空白,既保留照片背景完整性,又能无缝融入艺术元素,广受关注。

PhotoDoodle: AI tool for adding artistic doodles to photos with text commands-1


 

Function List

  • 文本驱动的艺术编辑:通过文字描述(如“添加卡通怪物”或“增加光环效果”),自动生成相应的涂鸦元素。
  • 少样本学习支持:只需少量用户提供的配对数据,就能学习并生成个性化编辑风格。
  • 高质量虚实融合:确保新添加的元素与照片背景在视角、光影上自然融合。
  • 数据集与模型开放:提供预训练模型和多样化风格数据集,支持用户直接下载使用。
  • Open Source Support:允许开发者修改代码或集成到其他项目中,灵活性高。
  • 批量处理能力:支持一次性编辑多张图片,提高效率。

 

Using Help

PhotoDoodle 是一个基于 GitHub 的开源项目,用户需要一定的技术基础来安装和使用。以下是详细的安装与使用指南,帮助你快速上手。

Installation process

  1. environmental preparation
    • 确保你的电脑已安装 Git、Python 3.11.10 和 Conda。
    • Open a terminal and enter the following command to clone the project locally:
      git clone git@github.com:showlab/PhotoDoodle.git
      cd PhotoDoodle
      
    • Create and activate a virtual environment:
      conda create -n doodle python=3.11.10
      conda activate doodle
      
  2. Installation of dependencies
    • 安装 PyTorch(建议使用 CUDA 加速版本,若有 GPU):
      pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu124
      
    • 安装其他依赖:
      pip install --upgrade -r requirements.txt
      
    • 等待安装完成,确保网络畅通。
  3. Download pre-trained model
    • 项目提供了多个预训练模型,需手动下载。访问 PhotoDoodle 的 GitHub Releases 或 Hugging Face 数据集页面,下载模型文件(如 OmniEditor cap (a poem) EditLoRA).
    • 将下载的模型文件放入项目目录下的指定文件夹(参考 README 中的路径说明,通常为 checkpoints/).
  4. Verify Installation
    • 在终端运行测试命令(如 README 中提供的示例脚本),检查是否报错。若无错误,安装成功。

Usage

PhotoDoodle 的核心功能是通过文本指令编辑照片,操作分为两种场景:直接使用预训练模型和自定义训练。

使用预训练模型编辑照片

  1. Prepare the picture
    • 将需要编辑的照片(如 source.jpg) into the project directory under the input/ 文件夹(若无此文件夹,自行创建)。
  2. Run the edit command
    • 在终端输入以下命令(假设已激活 doodle 环境):
      python inference.py --source input/source.jpg --prompt "在照片上添加卡通风格的翅膀" --output output/result.jpg
      
    • Parameter Description:
      • --source:源照片路径。
      • --prompt:文本指令,描述想要添加的元素。
      • --output:输出结果路径。
    • 运行后,生成的结果会保存在 output/result.jpgThe
  3. View Results
    • show (a ticket) output/ 文件夹,检查生成的图片。调整指令(如“增加光影效果”)可生成不同风格。

自定义训练个性化风格

  1. 准备配对数据集
    • Create a .jsonl Files (e.g. dataset.jsonl),每行记录一对图片和描述:
      {"source": "path/to/source.jpg", "target": "path/to/modified.jpg", "caption": "添加蓝色光环"}
      {"source": "path/to/source2.jpg", "target": "path/to/modified2.jpg", "caption": "增加卡通怪物"}
      
    • 至少准备 5-10 对图片,反映你的风格需求。
  2. Run the training script
    • commander-in-chief (military) .jsonl file into the project directory and execute it:
      python train.py --data dataset.jsonl --model OmniEditor --output_dir trained_model/
      
    • The training time depends on the amount of data and hardware performance (GPU recommended), and after completion the model is saved in the trained_model/The
  3. Editing with Custom Models
    • Inference using trained models:
      python inference.py --source input/source.jpg --prompt "Add my style elements" --model trained_model/checkpoint.pth --output output/custom_result.jpg
      
    • Check the output to verify that it meets expectations.

Operation process details

  • Batch Edit: Place multiple images into the input/ folder, the modification script supports loop processing (e.g., adding the ---batch parameter, refer to the code comments for implementation details).
  • Adjustment effect: If the blending is not natural, add a detailed description to the cue (e.g., "consistent with the background lighting") or adjust the model parameters (see config/ (Documentation).
  • Debugging Issues: If something goes wrong, check the Python version, the dependencies for completeness, or check GitHub Issues for community help.

caveat

  • Hardware Requirements: GPU (e.g. NVIDIA CUDA support) is recommended for speed, CPU can run but is slower.
  • Data quality: the higher the resolution of the input image, the better the result; the customized dataset needs to be consistent.
  • Online experience: Some features can be tested online via Hugging Face Spaces without local installation.

With these steps, you can easily add artistic appeal to your photos with PhotoDoodle, whether it's a quick trial or deep customization.

CDN1
May not be reproduced without permission:Chief AI Sharing Circle " PhotoDoodle: AI tool for adding artistic doodles to photos with text commands

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish