Skip to content

Instantly share code, notes, and snippets.

View Bardia323's full-sized avatar
💭
🧠🤺

Bardia Shahrestani Bardia323

💭
🧠🤺
View GitHub Profile
@Bardia323
Bardia323 / find_noise.py
Last active September 24, 2022 15:08 — forked from trygvebw/find_noise.py
A "reverse" version of the k_euler sampler for Stable Diffusion, which finds the noise that will reconstruct the supplied image
import torch
import numpy as np
import k_diffusion as K
from PIL import Image
from torch import autocast
from einops import rearrange, repeat
def pil_img_to_torch(pil_img, half=False):
image = np.array(pil_img).astype(np.float32) / 255.0