This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler | |
from torch | |
from PIL import Image | |
def image_grid(imgs, rows, cols): | |
assert len(imgs) == rows*cols | |
w, h = imgs[0].size | |
grid = Image.new('RGB', size=(cols*w, rows*h)) | |
grid_w, grid_h = grid.size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import safetensors.torch | |
import sys | |
def dump_keys(parent, suffix=''): | |
for k in sorted(parent.keys()): | |
if isinstance(parent[k], torch.Tensor): | |
print(f'{suffix}{k} {list(parent[k].shape)}') | |
else: | |
dump_keys(parent[k], f'{suffix}{k}.') |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn | |
def test_monkey_patch(): | |
x = torch.randn((2, 2)).cuda() | |
target = torch.nn.Linear(2, 2).cuda() | |
with torch.no_grad(): | |
y = target(x) | |
assert y.shape == (2, 2) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import safetensors.torch | |
import sys | |
def dump_keys(parent, suffix=''): | |
for k in sorted(parent.keys()): | |
if isinstance(parent[k], torch.Tensor): | |
print(f'{suffix}{k} {list(parent[k].shape)} mean={torch.mean(parent[k]):.3g} std={torch.std(parent[k]):.3g}') | |
else: | |
dump_keys(parent[k], f'{suffix}{k}.') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler | |
def create_pipeline(): | |
pipe = StableDiffusionPipeline.from_pretrained( | |
"gsdf/Counterfeit-V2.5", torch_dtype=torch.float16, safety_checker=None | |
).to("cuda") | |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config, use_karras_sigmas=True) | |
pipe.enable_xformers_memory_efficient_attention() | |
return pipe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler | |
def create_pipeline(): | |
pipe = StableDiffusionPipeline.from_pretrained( | |
"gsdf/Counterfeit-V2.5", torch_dtype=torch.float16, safety_checker=None | |
).to("cuda") | |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config, use_karras_sigmas=True) | |
pipe.enable_xformers_memory_efficient_attention() | |
return pipe |