Views
No views yet

1conda create -n nextstep python=3.11 -y
2conda activate nextstep
3
4pip install uv # optional
5
6GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/stepfun-ai/NextStep-1-Large-Edit && cd NextStep-1-Large-Edit
7uv pip install -r requirements.txt
8
9hf download stepfun-ai/NextStep-1-Large-Edit "vae/checkpoint.pt" --local-dir ./1from PIL import Image
2from transformers import AutoTokenizer, AutoModel
3from models.gen_pipeline import NextStepPipeline
4from utils.aspect_ratio import center_crop_arr_with_buckets
5
6HF_HUB = "stepfun-ai/NextStep-1-Large-Edit"
7
8# load model and tokenizer
9tokenizer = AutoTokenizer.from_pretrained(HF_HUB, local_files_only=True, trust_remote_code=True,force_download=True)
10model = AutoModel.from_pretrained(HF_HUB, local_files_only=True, trust_remote_code=True,force_download=True)
11pipeline = NextStepPipeline(tokenizer=tokenizer, model=model).to(device=f"cuda")
12
13# set prompts
14positive_prompt = None
15negative_prompt = "Copy original image."
16example_prompt = "<image>" + "Add a pirate hat to the dog's head. Change the background to a stormy sea with dark clouds. Include the text 'NextStep-Edit' in bold white letters at the top portion of the image."
17
18# load and preprocess reference image
19IMG_SIZE = 512
20ref_image = Image.open("./assets/origin.jpg")
21ref_image = center_crop_arr_with_buckets(ref_image, buckets=[IMG_SIZE])
22
23# generate edited image
24image = pipeline.generate_image(
25 example_prompt,
26 images=[ref_image],
27 hw=(IMG_SIZE, IMG_SIZE),
28 num_images_per_caption=1,
29 positive_prompt=positive_prompt,
30 negative_prompt=negative_prompt,
31 cfg=7.5,
32 cfg_img=2,
33 cfg_schedule="constant",
34 use_norm=True,
35 num_sampling_steps=50,
36 timesteps_shift=3.2,
37 seed=42,
38)[0]
39image.save(f"./assets/output.jpg")1@article{nextstepteam2025nextstep1,
2 title={NextStep-1: Toward Autoregressive Image Generation with Continuous Tokens at Scale},
3 author={NextStep Team and Chunrui Han and Guopeng Li and Jingwei Wu and Quan Sun and Yan Cai and Yuang Peng and Zheng Ge and Deyu Zhou and Haomiao Tang and Hongyu Zhou and Kenkun Liu and Ailin Huang and Bin Wang and Changxin Miao and Deshan Sun and En Yu and Fukun Yin and Gang Yu and Hao Nie and Haoran Lv and Hanpeng Hu and Jia Wang and Jian Zhou and Jianjian Sun and Kaijun Tan and Kang An and Kangheng Lin and Liang Zhao and Mei Chen and Peng Xing and Rui Wang and Shiyu Liu and Shutao Xia and Tianhao You and Wei Ji and Xianfang Zeng and Xin Han and Xuelin Zhang and Yana Wei and Yanming Xu and Yimin Jiang and Yingming Wang and Yu Zhou and Yucheng Han and Ziyang Meng and Binxing Jiao and Daxin Jiang and Xiangyu Zhang and Yibo Zhu},
4 journal={arXiv preprint arXiv:2508.10711},
5 year={2025}
6}