Skip to content

Instantly share code, notes, and snippets.

@htoyryla
htoyryla / sd1mp3.mpy
Created October 10, 2022 15:29
Stable diffusion text2image assigning combined embeddings to each UNet block
# stable diffusion tool
# @htoyryla github twitter instagram
# requires diffusers 0.3.0 and a trained model
# relies heavily on code from https://github.com/huggingface/diffusers
# neurokuvatreenit, stable diffusion, example 1b using LDM scheduler and 1c saving image at each iteration
# 1d: multiple subprompts with weights
@htoyryla
htoyryla / sd1mp2.py
Last active October 10, 2022 08:16
Stable diffusion text2image assigning different prompts to each UNet block EXPERIMENTAL
# stable diffusion tool
# @htoyryla github twitter instagram
# requires diffusers 0.4.0 and a trained model
# relies heavily on code from https://github.com/huggingface/diffusers
# neurokuvatreenit, stable diffusion, example 1b using LDM scheduler and 1c saving image at each iteration
# 1d: multiple subprompts with weights
@htoyryla
htoyryla / stadit.py
Last active September 21, 2022 07:18
Stable diffusion tool, image synthesis, img2img and prompt weights
# stable diffusion tool
# @htoyryla github twitter instagram
# requires diffusers 0.3.0 and a trained model
# relies heavily on code from https://github.com/huggingface/diffusers
# for prompt weighting use prompts like "a subprompt like this:10 / in the style of that:25"
@htoyryla
htoyryla / i2it.py
Last active September 8, 2022 15:07
Script for image2image using stablediffusion using incremental strength
from torch import autocast
import torch
import requests
from PIL import Image
import sys
from diffusers import StableDiffusionImg2ImgPipeline #, preprocess
import random
import argparse
# image to image generation using StableDiffusion 0.3.0 dev
@htoyryla
htoyryla / i2is.py
Last active August 27, 2022 16:06
script to generate 100 frames transition from init image towards the promp with Stablediffusion
from torch import autocast
import torch
import requests
from PIL import Image
import sys
from image_to_image import StableDiffusionImg2ImgPipeline, preprocess
import random
# script to generate 100 frames transition from init image towards the prompt
@htoyryla
htoyryla / vid2.py
Created August 26, 2022 11:49
Simple script to read frames from a video and use as init images in stablediffusion
#
# Usage:
#
# python vid2.py "prompt" video_in_path output_dir [strength scale seed]
#
# requires image_to_image.py from https://github.com/huggingface/diffusers/blob/main/examples/inference/image_to_image.py
#
from torch import autocast
@htoyryla
htoyryla / mdisco3.py
Created August 6, 2022 08:21
Basic disco diffusion with masks, command line only, config read from ini file
# %%
# !! {"metadata":{
# !! "id": "view-in-github",
# !! "colab_type": "text"
# !! }}
"""
<a href="https://colab.research.google.com/github/alembics/disco-diffusion/blob/main/Disco_Diffusion.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
"""
# %%
@htoyryla
htoyryla / _ht_gan.txt
Last active June 11, 2018 11:13
HT-GAN including AE and growing image size
code for a gan trainer
adding an encoder to assist in generator training
htoyryla 8 Jun 2018
support for progressive training with larger image size
htoyryla 11.6.2018
-- modified version of @jcjohnson's neural-style
-- by @htoyryla 14 Feb 2018
-- allows exploring the effect of equalizing the activations of different channels in a style layer
require 'torch'
require 'nn'
require 'image'
require 'optim'
-- modified version of @jcjohnson's neural-style
-- by @htoyryla 13 Feb 2018
-- allows giving emphasis to nc best channel(s) in each style layer
-- use -style_layers to select layer as usual, using a single layer is recommended
-- -nc to set how many of the best channels are used per layer
-- during target capture, tests the model using the style image
-- and selects nc channels with strongest activations to be given emphasis during iterations
-- not tested with multiple style images
require 'torch'