Skip to content

Instantly share code, notes, and snippets.

@Norod
Norod / sd-simpsons-model-DPMSolverMultistepScheduler.py
Created November 10, 2022 20:31
Inference for sd-simpsons-model using DPMSolverMultistepScheduler
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
import torch
def main():
#////////////////////////////////////////////
seed = 42
model = "Norod78/sd-simpsons-model"
#////////////////////////////////////////////
@Norod
Norod / DPMSolverMultistepScheduler-stable-cpu.py
Created November 8, 2022 14:11
CPU stable-diffusion-v1-5 inference using DPMSolverMultistepScheduler
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
import torch
def main():
#////////////////////////////////////////////
seed = 42
model = "runwayml/stable-diffusion-v1-5"
#////////////////////////////////////////////
@Norod
Norod / hebrew-poem-generator-flaxgptneoforcausallm-inference-tpu.ipynb
Created November 3, 2022 13:12
Hebrew-Poem-Generator-FlaxGPTNeoForCausalLM-inference-TPU.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Norod
Norod / buildimagedatasetwithblipcaptionsanduploadtohf.ipynb
Created November 3, 2022 11:26
BuildImageDatasetWithBlipCaptionsAndUploadToHF.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Norod
Norod / patch_for_wsl2_pytorch191_no-xformers_needs-disable-unsafe-pickle.diff
Created October 26, 2022 12:53
Patch AUTOMATIC1111/stable-diffusion-webui to work on wsl2 with torch 1.9.1+cu111 (no xformers, needs disable-unsafe-pickle, no mem monitoring)
diff --git a/.gitignore b/.gitignore
index 70660c5..6b51c8e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,3 +30,6 @@ notification.mp3
.vscode
/extensions
+cache
+gfpgan/
@Norod
Norod / vae-test.py
Last active September 28, 2022 08:51
Encapsulate an encoded VAE latent as PNG image, then load it and use it to decode the original image
#!pip install diffusers==0.2.4
import torch
from diffusers import AutoencoderKL
from PIL import Image
import numpy as np
from torchvision import transforms as tfms
torch_device = None
vae = None
@Norod
Norod / patch_checker.py
Last active October 14, 2022 18:44
Patches safety_checker in diffuser's stable_diffusion pipeline to not blacken the potential NSFW image. The caller can still decide what to do with it based on the value of has_nsfw_concept[index]
import importlib
checker_location = importlib.util.find_spec('diffusers.pipelines.stable_diffusion.safety_checker').origin
checker_location_flax = importlib.util.find_spec('diffusers.pipelines.stable_diffusion.safety_checker_flax').origin
blocker_location_flax = importlib.util.find_spec('diffusers.pipelines.stable_diffusion.pipeline_flax_stable_diffusion').origin
#FlaxStableDiffusionPipeline
import fileinput
@Norod
Norod / stable-cpu.py
Created August 28, 2022 15:04
Stable Diffusion, running on CPU, uses hugging-face diffusers library
#### pip install diffusers==0.2.4 transformers scipy ftfy
####
from diffusers import StableDiffusionPipeline, LMSDiscreteScheduler
import torch
def main():
seed = 1000 #1000, 42, 420
torch.manual_seed(seed)
generator = torch.Generator()
@Norod
Norod / stable-diffusion-model-text-to-image-with-google-drive-caching.ipynb
Created August 24, 2022 14:28
stable-diffusion-model-text-to-image-with-google-drive-caching.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Norod
Norod / latent-diffusion-laion-400m-model-text-to-image-with-google-drive-caching.ipynb
Created August 10, 2022 15:07
latent-diffusion-laion-400m-model-text-to-image-with-google-drive-caching.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.