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 numpy as np | |
import cv2 | |
def NormalComposition(srcRGBA, dstRGBA): | |
srcA = np.dstack((srcRGBA[:,:,3]/255,)*3) | |
srcRGB = srcRGBA[:,:,:3] | |
dstA = np.dstack((dstRGBA[:,:,3]/255,)*3) | |
dstRGB = dstRGBA[:,:,:3] | |
outA = srcA + dstA*(1-srcA) |
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 lark | |
class WeightedTree(lark.Tree): | |
pass | |
prompt_grammar = lark.Lark(r""" | |
!start: (prompt | /[][():]/+)* | |
prompt: (emphasis | deemphasis | numeric | scheduled | alternate | plain | WHITESPACE)* | |
emphasis: "(" prompt ")" | |
deemphasis: "[" prompt "]" |
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 | |
allowed_keys = [ | |
"encoder", | |
"decoder", | |
"quant_conv", | |
"post_quant_conv"] | |
def extract_vae(model, half=False): | |
out = {} |
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
#!/usr/bin/python | |
import torch | |
import safetensors | |
import safetensors.torch | |
import os | |
MODEL_KEYS = [ | |
"model.", | |
"first_stage_model", |
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 argparse, os, sys, glob | |
import urllib.request | |
import statistics | |
# put this script in stable-diffusion-webui and run it: python squarize.py | |
# the model will be downloaded and the squarize folder will be created. | |
# all images in squarize/input get processed and inpainted, ending up in squarize/output | |
# *stable-diffusion-webui needs to be working |
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
#!/usr/bin/python | |
import os | |
import re | |
import json | |
import random | |
from PIL import Image, ImageDraw, ImageOps | |
from multiprocessing import Pool | |
import subprocess | |
import sys | |
import urllib.request |