Skip to content

Instantly share code, notes, and snippets.

View ryanwebster90's full-sized avatar

Ryan Webster ryanwebster90

View GitHub Profile
{
"model": {
"type": "image_v1",
"input_channels": 3,
"input_size": [64, 64],
"mapping_out": 256,
"depths": [2, 2, 4, 4],
"channels": [128, 256, 256, 512],
"self_attn_depths": [false, false, true, true],
"dropout_rate": 0.05,
import numpy as np
import torch
import fire
import glob
def abs_ind_to_feat_file(abs_ind, cum_sz, feat_files):
inds = np.argwhere(abs_ind - cum_sz >= 0)
last_ind = inds[-1].item()
ind_offset = cum_sz[last_ind]
local_ind = abs_ind - ind_offset
from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler
import torch
scheduler = EulerDiscreteScheduler(use_karras_sigmas=True)
pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5",scheduler=scheduler, torch_dtype=torch.float16)
generator = torch.Generator("cuda").manual_seed(0)
pipe = pipe.to('cuda')
image = pipe("a golden retriever",num_inference_steps=30,generator=generator).images[0]
image.save('test.jpg')