Skip to content

Instantly share code, notes, and snippets.

View stevenwaterman's full-sized avatar

Steven Waterman stevenwaterman

View GitHub Profile
@stevenwaterman
stevenwaterman / multiUnet.py
Last active June 15, 2024 17:36
A Unet shim for stable diffusion diffusers that combines multiple models in varying amounts at runtime
# sd_unet = UNet2DConditionModel.from_pretrained("./stable-diffusion-v1-5", subfolder="unet")
# any_unet = UNet2DConditionModel.from_pretrained("./anything-v3", subfolder="unet")
# pipe = StableDiffusionPipeline(
# vae = ,
# text_encoder = ,
# tokenizer = ,
# unet = MultiUnet([(sd_unet, 0.4), (any_unet, 0.6)], "cuda"),
# scheduler = ,
# safety_checker = ,
# feature_extractor =
@stevenwaterman
stevenwaterman / pipeline.ts
Last active August 20, 2020 14:43
Typescript 4 is a magical thing
type Tail<XS extends readonly any[]> = XS extends readonly [any, ...infer T] ? T : [];
type Last<XS extends readonly any[]> = XS extends readonly [...infer _, infer X] ? X : never;
type UnionToIntersection<U> = (U extends any ? (k: U)=>void : never) extends ((k: infer I)=>void) ? I : never;
type Equal<A, B> = A extends B ? B extends A ? true : false : false;
type PipelineStage<Input, Config extends Record<any, unknown>, Output> = (input: Input, config: Config) => Output;
type Input<Stage extends PipelineStage<any, any, any>> = Parameters<Stage>[0];
type Config<Stage extends PipelineStage<any, any, any>> = Parameters<Stage>[1];
type Output<Stage extends PipelineStage<any, any, any>> = ReturnType<Stage>;
@stevenwaterman
stevenwaterman / main.yml
Created February 24, 2020 08:53
A GitHub Actions worflow for automatic front-end build & deployment with GitHub Pages
name: AutomaticHost
on:
push:
branches:
- {BRANCH_NAME}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@stevenwaterman
stevenwaterman / Duplicates.java
Last active September 19, 2019 16:02
How to get list of all duplicates in two collections
public class Duplicates {
private static <T> BiFunction<Processing<T>, T, Processing<T>> getReducer(){
return (acc, elem) -> {
if (acc.uniques.contains(elem)) {
acc.dupes.add(elem);
} else {
acc.uniques.add(elem);
}
return acc;
};