Skip to content

Display each generation step #6991

Answered by asomoza
ran4erep asked this question in Q&A
Feb 16, 2024 · 6 comments · 7 replies
Discussion options

You must be logged in to vote

for the first method you just need to put the code I gave you together:

def latents_to_rgb(latents):
    weights = (
        (60, -60, 25, -70),
        (60,  -5, 15, -50),
        (60,  10, -5, -35)
    )

    weights_tensor = torch.t(torch.tensor(weights, dtype=latents.dtype).to(latents.device))
    biases_tensor = torch.tensor((150, 140, 130), dtype=latents.dtype).to(latents.device)
    rgb_tensor = torch.einsum("...lxy,lr -> ...rxy", latents, weights_tensor) + biases_tensor.unsqueeze(-1).unsqueeze(-1)
    image_array = rgb_tensor.clamp(0, 255)[0].byte().cpu().numpy()
    image_array = image_array.transpose(1, 2, 0)  # Change the order of dimensions

    return Image.fromarray(image_array

Replies: 6 comments 7 replies

Comment options

You must be logged in to vote
4 replies
@ran4erep
Comment options

@asomoza
Comment options

Answer selected by ran4erep
@ran4erep
Comment options

@henrymcl
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@sayakpaul
Comment options

@yiyixuxu
Comment options

Comment options

You must be logged in to vote
1 reply
@asomoza
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants