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 / neural_mirage5.lua
Last active September 2, 2018 14:26
Neural-style modified to use also fc layers
--[[
Neural-mirage 5
by @htoyryla 3/2016, 3/2017
based on neural-style by @jcjohnson
for more info see
http://liipetti.net/erratic/2016/03/31/i-have-seen-a-neural-mirage/
http://liipetti.net/erratic/2016/04/20/getting-the-space-back/
@htoyryla
htoyryla / original_colors.lua
Last active June 18, 2018 19:25
Use original colors in an image generated by fast-neural-style
-- this program takes an original image, such as a photo,
-- and a generated image, such as generated by jcjohnson/fast-neural-style
-- and copies the original colors to the generated image
-- like when using the original_colors param in jcjohnson/neural-style
--
-- by hannu töyrylä @htoyryla 30 oct 2016
--
require 'torch'
require 'image'
@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