Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/diffusers/models/transformers/transformer_bria_fibo.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def __init__(
self.time_embed = BriaFiboTimestepProjEmbeddings(embedding_dim=self.inner_dim, time_theta=time_theta)

if guidance_embeds:
self.guidance_embed = BriaFiboTimestepProjEmbeddings(embedding_dim=self.inner_dim)
self.guidance_embed = BriaFiboTimestepProjEmbeddings(embedding_dim=self.inner_dim, time_theta=time_theta)

self.context_embedder = nn.Linear(self.config.joint_attention_dim, self.inner_dim)
self.x_embedder = torch.nn.Linear(self.config.in_channels, self.inner_dim)
Expand Down Expand Up @@ -555,7 +555,7 @@ def forward(

temb = self.time_embed(timestep, dtype=hidden_states.dtype)

if guidance:
if guidance is not None:
temb += self.guidance_embed(guidance, dtype=hidden_states.dtype)

encoder_hidden_states = self.context_embedder(encoder_hidden_states)
Expand Down
14 changes: 10 additions & 4 deletions src/diffusers/pipelines/bria_fibo/pipeline_bria_fibo.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ def encode_prompt(
)
prompt_embeds = prompt_embeds.to(dtype=self.transformer.dtype)
prompt_layers = [tensor.to(dtype=self.transformer.dtype) for tensor in prompt_layers]
else:
raise ValueError(
"`prompt_embeds` cannot be passed on its own; this pipeline also needs the per-layer embeddings "
"computed from `prompt`. Please pass `prompt` instead."
)

if guidance_scale > 1:
if isinstance(negative_prompt, list) and negative_prompt[0] is None:
Expand Down Expand Up @@ -773,10 +778,11 @@ def __call__(
for scaled_latent in latents_scaled:
curr_image = self.vae.decode(scaled_latent.unsqueeze(0), return_dict=False)[0]
curr_image = self.image_processor.postprocess(curr_image.squeeze(dim=2), output_type=output_type)
image.append(curr_image)
if len(image) == 1:
image = image[0]
else:
if output_type == "np":
image.append(curr_image[0])
else:
image.extend(curr_image)
if output_type == "np":
image = np.stack(image, axis=0)

# Offload all models
Expand Down
16 changes: 11 additions & 5 deletions src/diffusers/pipelines/bria_fibo/pipeline_bria_fibo_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,11 @@ def encode_prompt(
)
prompt_embeds = prompt_embeds.to(dtype=self.transformer.dtype)
prompt_layers = [tensor.to(dtype=self.transformer.dtype) for tensor in prompt_layers]
else:
raise ValueError(
"`prompt_embeds` cannot be passed on its own; this pipeline also needs the per-layer embeddings "
"computed from `prompt`. Please pass `prompt` instead."
)

if guidance_scale > 1:
if isinstance(negative_prompt, list) and negative_prompt[0] is None:
Expand Down Expand Up @@ -807,7 +812,7 @@ def __call__(
prompt_layers = prompt_layers + [prompt_layers[-1]] * (total_num_layers_transformer - len(prompt_layers))

# Preprocess image
if image is not None and not (isinstance(image, torch.Tensor) and image.size(1) == self.latent_channels):
if image is not None:
image = self.image_processor.resize(image, height, width)
image = self.image_processor.preprocess(image, height, width)

Expand Down Expand Up @@ -996,10 +1001,11 @@ def __call__(
for scaled_latent in latents_scaled:
curr_image = self.vae.decode(scaled_latent.unsqueeze(0), return_dict=False)[0]
curr_image = self.image_processor.postprocess(curr_image.squeeze(dim=2), output_type=output_type)
image.append(curr_image)
if len(image) == 1:
image = image[0]
else:
if output_type == "np":
image.append(curr_image[0])
else:
image.extend(curr_image)
if output_type == "np":
image = np.stack(image, axis=0)

# Offload all models
Expand Down
Loading