🚀 AnyStory:文本到图像生成中实现统一的单主体和多主体个性化
AnyStory是一种用于个性化主体生成的统一方法。它不仅能为单主体实现高保真的个性化,还能为多主体实现这一目标,且不会牺牲主体的保真度。
这个模型仓库是关于 AnyStory 的。
✨ 主要特性
AnyStory是一种统一的个性化主体生成方法,具备以下特点:
- 能够为单主体和多主体实现高保真的个性化。
- 在多主体个性化过程中,不会牺牲主体的保真度。
📦 安装指南
文档中未提及具体安装步骤,暂不提供。
💻 使用示例
基础用法
import torch
from PIL import Image
from huggingface_hub import hf_hub_download
from anystory.generate import AnyStoryFluxPipeline
anystory_path = hf_hub_download(repo_id="Junjie96/AnyStory", filename="anystory_flux.bin")
story_pipe = AnyStoryFluxPipeline(
hf_flux_pipeline_path="black-forest-labs/FLUX.1-dev",
hf_flux_redux_path="black-forest-labs/FLUX.1-Redux-dev",
anystory_path=anystory_path,
device="cuda",
torch_dtype=torch.bfloat16
)
subject_image = Image.open("assets/examples/1.webp").convert("RGB")
subject_mask = Image.open("assets/examples/1_mask.webp").convert("L")
prompt = "Cartoon style. A sheep is riding a skateboard and gliding through the city," \
" holding a wooden sign that says \"hello\"."
image = story_pipe.generate(prompt=prompt, images=[subject_image], masks=[subject_mask], seed=2025,
num_inference_steps=25, height=512, width=512,
guidance_scale=3.5)
image.save("output_1.png")
subject_image_1 = Image.open("assets/examples/6_1.webp").convert("RGB")
subject_mask_1 = Image.open("assets/examples/6_1_mask.webp").convert("L")
subject_image_2 = Image.open("assets/examples/6_2.webp").convert("RGB")
subject_mask_2 = Image.open("assets/examples/6_2_mask.webp").convert("L")
prompt = "Two men are sitting by a wooden table, which is laden with delicious food and a pot of wine. " \
"One of the men holds a wine glass, drinking heartily with a bold expression; " \
"the other smiles as he pours wine for his companion, both of them engaged in cheerful conversation. " \
"In the background is an ancient pavilion surrounded by emerald bamboo groves, with sunlight filtering " \
"through the leaves to cast dappled shadows."
image = story_pipe.generate(prompt=prompt,
images=[subject_image_1, subject_image_2],
masks=[subject_mask_1, subject_mask_2],
seed=2025,
enable_router=True, ref_start_at=0.09,
num_inference_steps=25, height=512, width=512,
guidance_scale=3.5)
image.save("output_2.png")
故事板生成
import json
from storyboard import StoryboardPipeline
storyboard_pipe = StoryboardPipeline()
storyboard_pipe.new_story()
script_dict = json.load(open("assets/scripts/013420.json"))
print(script_dict)
results = storyboard_pipe(script_dict, style_name="Comic book")
for key, result in results.items():
result.save(f"output_1_{key}.png")
storyboard_pipe.new_story()
script_dict = json.load(open("assets/scripts/014933.json"))
print(script_dict)
results = storyboard_pipe(script_dict, style_name="Japanese Anime")
for key, result in results.items():
result.save(f"output_2_{key}.png")
示例输出:
📚 详细文档
应用场景
🔧 技术细节
文档中未提及具体技术细节,暂不提供。
📄 许可证
本项目使用 apache-2.0
许可证。
👏 致谢
此代码基于 diffusers 和 OminiControl 构建。非常感谢他们的杰出工作!
📖 引用
@article{he2025anystory,
title={AnyStory: Towards Unified Single and Multiple Subject Personalization in Text-to-Image Generation},
author={He, Junjie and Tuo, Yuxiang and Chen, Binghui and Zhong, Chongyang and Geng, Yifeng and Bo, Liefeng},
journal={arXiv preprint arXiv:2501.09503},
year={2025}
}
📋 模型信息
属性 |
详情 |
基础模型 |
black-forest-labs/FLUX.1-dev |
语言 |
en |
库名称 |
diffusers |
许可证 |
apache-2.0 |
任务类型 |
文本到图像 |
项目页面 |
https://aigcdesigngroup.github.io/AnyStory/ |
📢 最新消息
- [2025/05/01] 我们发布了 AnyStory 的
FLUX.1-dev
版本的代码和演示。