Generator feed an image


In diffusion models generators are used to generate samples. E.g. from OpenAI

I am wondering if I can feed an image as initialization to this generator?

Where can I find more details about this generator like the source code?

I don’t understand how this should work and you can read more about pseudorandom number generators e.g. here.

As far as I know, the torch.Generator class is the equivalent of NumPy Generator, a class used for generating random numbers.

Regarding initializing with an image, this is possible, but to get differentiated results, you may want to combine that image with some random noise. Here is one function you can use to do that:

def image_scale_rand(image: torch.tensor, scale):
    # image should be converted into a torch tensor already and normalized between 0 and 1
    # scale is a number between 0 and 1, where 0 is just the image and 1 is noise
    return image * (1 - scale) + torch.rand_like(image) * scale