PhotoDoodle开源AI艺术编辑工具

https://youtu.be/8hMqjfJqp_8

描述:

PhotoDoodle 是由 ShowLab 开发的开源图像编辑工具,旨在通过人工智能技术为照片添加艺术化的涂鸦元素。用户只需输入简单的文本提示,如“为猫添加光环和翅膀”,即可在保持原始照片背景完整性的同时,生成与之自然融合的艺术元素。

功能:

  • 免费开源: 提供开放的代码和数据集,支持开发者自由探索与改进。
  • 多风格支持: 支持超过六种艺术风格,包括卡通、水彩等,满足多样化需求。
  • 精准编辑能力: 能够执行从细微调整到整体风格转换的复杂编辑任务,保持图像一致性。
  • 创新技术集成: 结合LoRA、EditLoRA和位置编码克隆技术,实现高效学习与精确操作。

亮点:

AI驱动的艺术创作: 利用先进的扩散模型(Flux.1)和LoRA技术,PhotoDoodle能够将普通照片转化为充满创意的艺术作品。
无缝元素融合: 借助EditLoRA技术,系统可学习艺术家风格并将其应用于新图像,确保自然过渡与视觉和谐。
像素级精度控制: 通过位置编码克隆技术,PhotoDoodle能准确记住原始图像的像素位置,使新增元素完美融入背景。
多样应用场景: 无论是为宠物添加趣味效果,还是设计奇幻场景,PhotoDoodle都能轻松应对,展现卓越的灵活性。

使用指南:

环境准备:

确保计算机已安装 Git、Python 3.11.10 和 Conda。
打开终端,克隆项目并进入目录:

git clone https://github.com/showlab/PhotoDoodle.git
cd PhotoDoodle

创建并激活虚拟环境:

conda create -n doodle python=3.11.10
conda activate doodle

安装依赖:

安装 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

下载预训练模型:

访问 PhotoDoodle 的 GitHub Releases 或 Hugging Face 数据集页面,下载所需的预训练模型文件(如 OmniEditor 和 EditLoRA)。

将下载的模型文件放入项目目录下的指定文件夹(通常为 checkpoints/)。

运行推理:

使用以下代码进行推理:

from src.pipeline_pe_clone import FluxPipeline
import torch
from PIL import Image

pretrained_model_name_or_path = "black-forest-labs/FLUX.1-dev"
pipeline = FluxPipeline.from_pretrained(
    pretrained_model_name_or_path,
    torch_dtype=torch.bfloat16,
).to('cuda')

pipeline.load_lora_weights("nicolaus-huang/PhotoDoodle", weight_name="pretrain.safetensors")
pipeline.fuse_lora()
pipeline.unload_lora_weights()

pipeline.load_lora_weights("nicolaus-huang/PhotoDoodle", weight_name="sksmagiceffects.safetensors")

height = 768
width = 512

validation_image = "assets/1.png"
validation_prompt = "add a halo and wings for the cat by sksmagiceffects"
condition_image = Image.open(validation_image).resize((height, width)).convert("RGB")

result = pipeline(
    prompt=validation_prompt,
    condition_image=condition_image,
    height=height,
    width=width,
    guidance_scale=3.5,
    num_inference_steps=20,
    max_sequence_length=512
).images[0]

result.save("output.png")

或者直接运行推理脚本:

python inference.py

通过上述步骤,您即可使用 PhotoDoodle 为照片添加艺术化的涂鸦元素,创造独特的艺术作品。

资源:

油管:https://youtu.be/8hMqjfJqp_8

了解 Tarogo Cloud Bloger & Shop 的更多信息

立即订阅以继续阅读并访问完整档案。

继续阅读