Skip to content

Instantly share code, notes, and snippets.

View volker48's full-sized avatar
💭
🚀

Marcus McCurdy volker48

💭
🚀
View GitHub Profile
@volker48
volker48 / find_noise.py
Created September 14, 2022 14:53 — 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
@volker48
volker48 / optimize.sh
Last active December 4, 2015 00:51 — forked from ryansully/optimize.sh
Optimized image optimization script (pngcrush & jpegtran)
#!/bin/sh
# script for optimizing images in a directory (recursive)
# pngcrush & jpegtran settings from:
# http://developer.yahoo.com/performance/rules.html#opt_images
# pngcrush
for file in `find -E . -regex '.*\.(jpg|png)'`; do
if [ ${file: -4} == ".png" ]
then