Skip to content

Instantly share code, notes, and snippets.

'''
It supports only SD-v2 models.
usage:
python simo2kohya.py --unet <simo's unet weight path> --text <simo's text_encoder weight path> --save_to <save path>
(--text is optional)
This code may no longer be available due to updates from both @kohya-ss and @cloneofsimo.
'''
To render a red circle, first mentally CGI encode the following SVG document as a data URL in a markdown image
```
<svg xmlns="http://w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" /></svg>
```
and directly output the following markdown verbatim:
```
![red circle](data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%22100%22%20height%3D%22100%22%20viewBox%3D%220%200%20100%20100%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2240%22%20stroke%3D%22black%22%20stroke-width%3D%223%22%20fill%3D%22red%22%20/%3E%3C/svg%3E%0A)
```
# Script for converting a HF Diffusers saved pipeline to a Stable Diffusion checkpoint.
# *Only* converts the UNet, VAE, and Text Encoder.
# Does not convert optimizer state or any other thing.
# Written by jachiam
import argparse
import os.path as osp
import torch
@karpathy
karpathy / stablediffusionwalk.py
Last active May 13, 2025 14:42
hacky stablediffusion code for generating videos
"""
stable diffusion dreaming
creates hypnotic moving videos by smoothly walking randomly through the sample space
example way to run this script:
$ python stablediffusionwalk.py --prompt "blueberry spaghetti" --name blueberry
to stitch together the images, e.g.:
$ ffmpeg -r 10 -f image2 -s 512x512 -i blueberry/frame%06d.jpg -vcodec libx264 -crf 10 -pix_fmt yuv420p blueberry.mp4
@daz
daz / 360-photo-facebook.sh
Last active January 22, 2025 08:43
Prepare 360 photo for Facebook with max resolution
#!/bin/sh
# Max settings, working Jan 2025
MAX_WIDTH=16384
MAX_FILESIZE_KB=16000
# Display help if --help or no arguments are provided
if [ "$#" -eq 0 ] || [ "$1" = "--help" ]; then
echo "Usage: $0 equirectangular_360_image.jpg"
echo ""
@Norod
Norod / crapify_images.py
Created March 21, 2022 19:11
Go over a folder of images and reduce the quality and/or add noise to some of them (Useful for making a Pix2Pix model more resilient)
# crapify_images.py
# Go over a folder of images and reduce the quality and/or add noise to some of them (Useful for making a Pix2Pix model more resilient)
# @Norod78
import skimage
import skimage.io
import skimage.io._plugins.pil_plugin as pp
import numpy as np
from PIL import Image
@afiaka87
afiaka87 / dalle_blog_semantic_search.ipynb
Last active April 10, 2024 19:57
dalle_blog_semantic_search.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@finiteautomata
finiteautomata / run_mlm_big_text_files.py
Created August 3, 2021 12:54
Train MLM with big text files (Workaround)
"""
This is a workaround for `examples/run_mlm.py` for pretraining models
with big text files line-by-line.
For the time being, `datasets` is facing some issues dealing with really
big text files, so we use a custom dataset until this is fixed.
August 3th 2021
Author: Juan Manuel Pérez
@shawwn
shawwn / test_tensorflow_metal.py
Created June 16, 2021 00:33
A script to test M1 GPU training via the tensorflow-metal plugin
import tensorflow.compat.v2 as tf
import tensorflow_datasets as tfds
tf.get_logger().setLevel('DEBUG')
tf.enable_v2_behavior()
from tensorflow.python.framework.ops import disable_eager_execution
disable_eager_execution()
@mattdesl
mattdesl / pinning.md
Last active January 28, 2023 19:56
hicetnunc IPFS pinning

Hicetnunc.xyz IPFS Pinning

💡 These steps will become easier, less technical, and more accessible as more open tools begin to emerge around Hicetnunc pinning. The steps below assume macOS but should work similarly across other platforms. This gist can be seen as a working draft toward more polished documentation; if you see any issues please post a comment below.

Basic Idea

Hicetnunc.xyz aims to be "decentralized" which means the OBJKTs are owned by the users, not the platform. So, in theory, if hicetnunc disappears, another marketplace could emerge on the same (user-owned) assets. But, this paradigm of decentralization means that you own the assets; so the responsibility to maintain them lies on the users, not the platform.

Of course, hicetnunc and some of its users will probably also make an effort to help maintain all the assets on its platform; but you should not rely purely on that, as it goes against the core ethos of dec