Skip to content

Instantly share code, notes, and snippets.

import sys
import os
import platform
from importlib.metadata import version as pkg_version
from sdkit.utils import log
from easydiffusion import app
# future home of scripts/check_modules.py
@cmdr2
cmdr2 / diffusers_tensor_rt_directml.py
Last active June 1, 2023 06:28
TensorRT and DirectML with regular diffusers pipelines
import torch
import tensorrt as trt
from polygraphy import cuda
import sys
from packaging import version
from diffusers import StableDiffusionPipeline
from diffusers.pipelines.onnx_utils import OnnxRuntimeModel, ORT_TO_NP_TYPE
from dataclasses import dataclass
import numpy as np
import onnxruntime as ort
from sdkit import Context
from sdkit.generate import generate_images
from sdkit.utils import load_tensor_file, save_tensor_file
from ldm.util import instantiate_from_config
from omegaconf import OmegaConf
import time
model_path = "/path/to/models/stable-diffusion/sd-v1-4.ckpt"
import time
MODEL_PATH = "F:/models/stable-diffusion/sd-v1-4.ckpt"
CONFIG_PATH = "F:/models/stable-diffusion/v1-inference.yaml"
DEVICE = "mps" # or "cuda" or "cpu"
def diff():
print('diffusers')
import torch
from transformers import logging as tr_logging
"""
Runs the desired Stable Diffusion models against the desired samplers. Saves the output images
to disk, along with the peak RAM and VRAM usage, as well as the sampling performance.
"""
import argparse
import os
import time
import traceback
from pathlib import Path
import time
MODEL_PATH = "F:/models/stable-diffusion/sd-v1-4.ckpt"
CONFIG_PATH = "F:/models/stable-diffusion/v1-inference.yaml"
def diff():
print('diffusers')
import torch
from transformers import logging as tr_logging
tr_logging.set_verbosity_error() # suppress unnecessary logging
@cmdr2
cmdr2 / v2.1-inference.yaml
Last active December 24, 2022 21:48
Custom model config for Stable Diffusion 2.0 models, adds an "extra: {attn_precision: 'fp32'}" field to the end of the model config. This "extra" field is recognized by SDKit (https://github.com/easydiffusion/sdkit)
model:
base_learning_rate: 1.0e-4
target: ldm.models.diffusion.ddpm.LatentDiffusion
params:
parameterization: "v"
linear_start: 0.00085
linear_end: 0.0120
num_timesteps_cond: 1
log_every_t: 200
timesteps: 1000
@cmdr2
cmdr2 / sd1-vs-sd2.diff
Created November 24, 2022 04:39
Diff between https://github.com/CompVis/stable-diffusion (sd1) and https://github.com/Stability-AI/stablediffusion (sd2). Ran `diff -w -x '*.gif' -x '*.png' -x '*.jpg' -x LICENSE -x '*.md' -x '*.git' -r sd1 sd2 > d.txt`
Only in sd2: LICENSE-MODEL
Only in sd2/assets: stable-inpainting
Only in sd2/assets/stable-samples: depth2img
Only in sd2/assets/stable-samples/txt2img: 768
Only in sd2/assets/stable-samples: upscaling
Only in sd1/configs: autoencoder
Only in sd1/configs: latent-diffusion
Only in sd1/configs: retrieval-augmented-diffusion
Only in sd1/configs/stable-diffusion: v1-inference.yaml
Only in sd2/configs/stable-diffusion: v2-inference-v.yaml
// contributed by @madrang
PLUGINS['IMAGE_INFO_BUTTONS'].push({ text: 'Double Size (Madrang)', on_click: getStartNewTaskHandler('img2img_X2') })
PLUGINS['IMAGE_INFO_BUTTONS'].push({ text: 'Redo (Madrang)', on_click: getStartNewTaskHandler('img2img') })
function getStartNewTaskHandler(mode) {
return function(reqBody, img) {
const newTaskRequest = getCurrentUserRequest()
switch (mode) {
case 'img2img':
@cmdr2
cmdr2 / user_paths_blender_xr.diff
Created May 5, 2022 11:56
Diff for exposing user_path and user_path_other in the Blender XrEventData
diff --git a/source/blender/makesrna/intern/rna_xr.c b/source/blender/makesrna/intern/rna_xr.c
index 6f43afe23fe..52efa1b6653 100644
--- a/source/blender/makesrna/intern/rna_xr.c
+++ b/source/blender/makesrna/intern/rna_xr.c
@@ -1195,6 +1195,50 @@ static int rna_XrEventData_action_length(PointerRNA *ptr)
# endif
}
+static void rna_XrEventData_user_path_get(PointerRNA *ptr, char *r_value)
+{