Skip to content

Instantly share code, notes, and snippets.

@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 / buildimagedatasetwithblipcaptionsanduploadtohf.ipynb
Created November 3, 2022 11:26
BuildImageDatasetWithBlipCaptionsAndUploadToHF.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Norod
Norod / hebrew-poem-generator-flaxgptneoforcausallm-inference-tpu.ipynb
Last active January 26, 2025 12:26
hebrew-poem-generator-flaxgptneoforcausallm-inference-tpu.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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 / 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 / sd-simpsons-model-img2img.py
Last active December 1, 2022 11:33
Like the default HF StableDiffusion img2img sample, only it uses the sd2-simpsons-blip and DPMSolverMultistepScheduler
import requests
import torch
from PIL import Image
from io import BytesIO
from diffusers import StableDiffusionImg2ImgPipeline, DPMSolverMultistepScheduler
def main():
#////////////////////////////////////////////
seed = 42
@Norod
Norod / 3d_object_to_images-cpu.ipynb
Created November 22, 2022 16:08
3d_object_to_images-CPU.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Norod
Norod / two_tigers-StableDiffusionDepth2ImgPipeline.py
Created December 9, 2022 17:15
The Huggingface example code for stabilityai/stable-diffusion-2-depth (with GPU, CPU and multiple image results)
import torch
import requests
from PIL import Image
from diffusers import StableDiffusionDepth2ImgPipeline
def main():
device = "cuda" if torch.cuda.is_available() else "cpu"
dtype = torch.float16 if device == "cuda" else torch.float32
pipe = StableDiffusionDepth2ImgPipeline.from_pretrained(
@Norod
Norod / heb_eng_tokenize_compare.py
Created December 26, 2022 09:41
Compare the amount of tokens generated for a given Hebrew word input when an English and Hebrew tokenizers are used
from transformers import AutoTokenizer
tokenizer_heb = AutoTokenizer.from_pretrained("Norod78/hebrew-gpt_neo-small")
tokenizer_eng = AutoTokenizer.from_pretrained("gpt2")
prompt_text="שלום"
prompt_length = len(prompt_text)
encoded_prompt_heb = tokenizer_heb.encode(prompt_text, add_special_tokens=False, return_tensors="pt")
num_of_tokenz_heb = encoded_prompt_heb.size()[-1]
print(f"Hebrew tokenizer: Tokens = {num_of_tokenz_heb} length = {prompt_length}") #Hebrew tokenizer: Tokens = 1 length = 4
encoded_prompt_eng = tokenizer_eng.encode(prompt_text, add_special_tokens=False, return_tensors="pt")
@Norod
Norod / sd-diffusers-model-compare.py
Last active July 29, 2023 20:12
Compare two Stable-Diffusion diffuser models using a predifined set of prompts
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
import torch
#////////////////////////////////////////////////////////////////
guidance_scale=8.0
steps=40
width=512
height=512