Views
No views yet

FLUX.1-dev version of AnyStory.1import torch
2from PIL import Image
3
4from huggingface_hub import hf_hub_download
5from anystory.generate import AnyStoryFluxPipeline
6
7anystory_path = hf_hub_download(repo_id="Junjie96/AnyStory", filename="anystory_flux.bin")
8story_pipe = AnyStoryFluxPipeline(
9 hf_flux_pipeline_path="black-forest-labs/FLUX.1-dev",
10 hf_flux_redux_path="black-forest-labs/FLUX.1-Redux-dev",
11 anystory_path=anystory_path,
12 device="cuda",
13 torch_dtype=torch.bfloat16
14)
15# you can add lora here
16# story_pipe.flux_pipeline.load_lora_weights(lora_path, adapter_name="...")
17
18# single-subject
19subject_image = Image.open("assets/examples/1.webp").convert("RGB")
20subject_mask = Image.open("assets/examples/1_mask.webp").convert("L")
21prompt = "Cartoon style. A sheep is riding a skateboard and gliding through the city," \
22 " holding a wooden sign that says \"hello\"."
23image = story_pipe.generate(prompt=prompt, images=[subject_image], masks=[subject_mask], seed=2025,
24 num_inference_steps=25, height=512, width=512,
25 guidance_scale=3.5)
26image.save("output_1.png")
27
28# multi-subject
29subject_image_1 = Image.open("assets/examples/6_1.webp").convert("RGB")
30subject_mask_1 = Image.open("assets/examples/6_1_mask.webp").convert("L")
31subject_image_2 = Image.open("assets/examples/6_2.webp").convert("RGB")
32subject_mask_2 = Image.open("assets/examples/6_2_mask.webp").convert("L")
33prompt = "Two men are sitting by a wooden table, which is laden with delicious food and a pot of wine. " \
34 "One of the men holds a wine glass, drinking heartily with a bold expression; " \
35 "the other smiles as he pours wine for his companion, both of them engaged in cheerful conversation. " \
36 "In the background is an ancient pavilion surrounded by emerald bamboo groves, with sunlight filtering " \
37 "through the leaves to cast dappled shadows."
38
39image = story_pipe.generate(prompt=prompt,
40 images=[subject_image_1, subject_image_2],
41 masks=[subject_mask_1, subject_mask_2],
42 seed=2025,
43 enable_router=True, ref_start_at=0.09,
44 num_inference_steps=25, height=512, width=512,
45 guidance_scale=3.5)
46image.save("output_2.png")1import json
2from storyboard import StoryboardPipeline
3
4storyboard_pipe = StoryboardPipeline()
5
6storyboard_pipe.new_story()
7script_dict = json.load(open("assets/scripts/013420.json"))
8print(script_dict)
9results = storyboard_pipe(script_dict, style_name="Comic book")
10for key, result in results.items():
11 result.save(f"output_1_{key}.png")
12
13# 狮子王辛巴成长
14storyboard_pipe.new_story()
15script_dict = json.load(open("assets/scripts/014933.json"))
16print(script_dict)
17results = storyboard_pipe(script_dict, style_name="Japanese Anime")
18for key, result in results.items():
19 result.save(f"output_2_{key}.png")

storyboard.py)
assets/example_videos)1@article{he2025anystory,
2 title={AnyStory: Towards Unified Single and Multiple Subject Personalization in Text-to-Image Generation},
3 author={He, Junjie and Tuo, Yuxiang and Chen, Binghui and Zhong, Chongyang and Geng, Yifeng and Bo, Liefeng},
4 journal={arXiv preprint arXiv:2501.09503},
5 year={2025}
6}