Views
No views yet
1# 1. Create a virtual environment (recommended)
2python3 -m venv beam_env
3
4# 2. Activate the virtual environment
5source beam_env/bin/activate # On macOS/Linux
6# beam_env\Scripts\activate # On Windows
7
8pip install huggingface_hub
9huggingface-cli download Gui28F/BeamDiffusion2 --include requirements.txt --local-dir .
10
11# 3. Install required dependencies
12pip install -r ./requirements.txttransformers library to generate an image sequence based on a series of text prompts:1from huggingface_hub import snapshot_download
2
3# Download the model snapshot
4snapshot_download(repo_id="Gui28F/BeamDiffusion", local_dir="BeamDiffusionModel")
5from BeamDiffusionModel.beam_diffusion import BeamDiffusionPipeline, BeamDiffusionConfig, BeamDiffusionModel
6
7# Initialize the configuration, model, and pipeline
8config = BeamDiffusionConfig(sd="SD-2.1", latents_idx=[0, 1, 2, 3], n_seeds=4, steps_back=2, beam_width=2, window_size=2, use_rand=True)
9model = BeamDiffusionModel(config)
10pipe = BeamDiffusionPipeline(model)
11
12# Define the input parameters
13input_data = {
14 "steps": ["A lively outdoor celebration with guests gathered around, everyone excited to support the event.",
15 "A chef in a cooking uniform raises one hand dramatically, signaling it's time to serve the food.",
16 "Guests chat and laugh in a vibrant setting, with people gathered around tables, enjoying the event."],
17}
18
19# Generate the sequence of images
20sequence_imgs = pipe(input_data)
sd (str): The base model to use for image generation. The available options are SD-2.1 and flux.steps (list of strings): Descriptions for each step in the image generation process. The model generates one image per step, forming a sequence that aligns with these descriptions.latents_idx (list of integers): Indices referring to specific positions in the latent space to be used during image generation. This allows the model to leverage different latent representations for diverse outputs.n_seeds (int): Number of random seeds to use for the generation process. Each seed provides a different starting point for the randomness in the first step, influencing the diversity of generated sequences.seeds (list of integers): Specific seeds to use for the generation process. If provided, these seeds override the n_seeds parameter, allowing for controlled randomness.steps_back (int): Number of previous steps to consider during the beam search process. This parameter helps refine the current generation by incorporating information from earlier steps.beam_width (int): Number of candidate sequences to maintain during inference. Beam search evaluates multiple potential outputs and keeps the most probable ones based on the defined criteria.window_size (int): Size of the "window" for beam search pruning. Determines after how many steps pruning starts, helping the model focus on more probable options as the generation progresses.use_rand (bool): Flag to introduce randomness in the inference process. If set to True, the model generates more varied and creative results; if False, it produces more deterministic outputs.@misc{fernandes2025latentbeamdiffusionmodels,
title={Latent Beam Diffusion Models for Generating Visual Sequences},
author={Guilherme Fernandes and Vasco Ramos and Regev Cohen and Idan Szpektor and João Magalhães},
year={2025},
eprint={2503.20429},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2503.20429},
}