英文

基于指令优化的稳定扩散卡通化(从头开始)

该流程是 Stable Diffusion (v1.5) 的“指令优化”版本。它是使用 InstructPix2Pix methodology 进行训练的。

流程描述

这个流程部分地受到 FLAN 的启发,部分地受到 InstructPix2Pix 的启发。主要思想是首先创建一个指令提示的数据集(如 our blog 中所述),然后进行InstructPix2Pix样式的训练。最终目标是使稳定扩散更好地遵循涉及图像转换相关操作的特定指令。

参考 this post 了解更多信息。

训练过程和结果

训练是在 instruction-tuning-sd/cartoonization 数据集上进行的。请参考 this repository 了解更多信息。

以下是从流程中得出的一些结果:

预期用途和限制

您可以使用该流程对输入图像和输入提示进行卡通化处理。

使用方法

使用该模型的方法如下:

import torch
from diffusers import StableDiffusionInstructPix2PixPipeline
from diffusers.utils import load_image

model_id = "instruction-tuning-sd/scratch-cartoonizer"
pipeline = StableDiffusionInstructPix2PixPipeline.from_pretrained(
    model_id, torch_dtype=torch.float16, use_auth_token=True
).to("cuda")

image_path = "https://hf.co/datasets/diffusers/diffusers-images-docs/resolve/main/mountain.png"
image = load_image(image_path)

image = pipeline("Cartoonize the following image", image=image).images[0]
image.save("image.png")

有关限制、误用、恶意使用和超出范围使用的注意事项,请参考模型卡 here 。

引用

FLAN

@inproceedings{
    wei2022finetuned,
    title={Finetuned Language Models are Zero-Shot Learners},
    author={Jason Wei and Maarten Bosma and Vincent Zhao and Kelvin Guu and Adams Wei Yu and Brian Lester and Nan Du and Andrew M. Dai and Quoc V Le},
    booktitle={International Conference on Learning Representations},
    year={2022},
    url={https://openreview.net/forum?id=gEZrGCozdqR}
}

InstructPix2Pix

@InProceedings{
    brooks2022instructpix2pix,
    author     = {Brooks, Tim and Holynski, Aleksander and Efros, Alexei A.},
    title      = {InstructPix2Pix: Learning to Follow Image Editing Instructions},
    booktitle  = {CVPR},
    year       = {2023},
}

稳定扩散指令优化博客

@article{
  Paul2023instruction-tuning-sd,
  author = {Paul, Sayak},
  title = {Instruction-tuning Stable Diffusion with InstructPix2Pix},
  journal = {Hugging Face Blog},
  year = {2023},
  note = {https://huggingface.co/blog/instruction-tuning-sd},
}