Skip to content

Instantly share code, notes, and snippets.

@karpathy
karpathy / stablediffusionwalk.py
Last active April 12, 2025 23:27
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
@afiaka87
afiaka87 / zeta_quantize.ipynb
Last active November 27, 2023 04:43
zeta_quantize.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@voodoohop
voodoohop / render_training_video.py
Last active May 7, 2021 19:38
Creates a video from sequential training progress images. Skips more and more frames as iterations increase.
from glob import glob
# Creates a video from a folder containing images of training progress
# Allows sampling the image less often as iterations increase
# (Requires images be sortable by filename for now. Could use modification date too)
def render_video(output_path="/content/taming-transformers/output.mp4", src_path="/content/taming-transformers/", file_glob="*.png", step_increase_every=100):
tmp_path = "/tmp/latentvisions_tmp"
files = glob(src_path+file_glob)
files.sort()
@PotOfCoffee2Go
PotOfCoffee2Go / cellular automata RLE parser.md
Last active March 15, 2024 08:52
Javascript cellular automata RLE parser

RLE parser usage

See the RLE section for definition of RLE format.

This class expects the (extended) RLE input to be correctly formatted. It is a two state parser, thus multi-state RLE will not parse properly.

The output this.pattern is a string with spaces(dead)/zero(alive) with lines separated by '\n'.

@techtheriac
techtheriac / lambdajs.md
Last active December 28, 2020 20:19
A subtle introduction to Lambda Calculus for the JavaScript Developer

Lambda (λ) Calculus For Javascript Developers

This article aims at explaining lambda calculus in a more approachable less 'mathy' manner.

Terms That Are Good To Know

  • Memoization: Memoization is an optimization technique used primarily to speed up computer programs by caching the result of expensive function calls and returning the cached result when fed with the same input.

  • Pure Function: A pure function is a function whose computation does not depend on globally declared variables, it does no I/O or mutations. All it does is return a value after doing a bunch of computations on the arguments it recieves. For a given set of arguments, a pure function will always return the same value. Thus, a pure function is one that is memoizable.

@keunwoochoi
keunwoochoi / pseudo_cqt_pytorch.py
Last active March 22, 2023 15:08
To compute pseudo CQT (Constant-Q-transform using STFT) on Pytorch.
cqt_filter_fft = librosa.constantq.__cqt_filter_fft
class PseudoCqt():
"""A class to compute pseudo-CQT with Pytorch.
Written by Keunwoo Choi
API (+implementations) follows librosa (https://librosa.github.io/librosa/generated/librosa.core.pseudo_cqt.html)
Usage:
src, _ = librosa.load(filename)
src_tensor = torch.tensor(src)
@alexanderlerch
alexanderlerch / data-sets.md
Last active March 28, 2025 08:25
list of MIR datasets
dataset meta data contents with audio
200DrumMachines 7371 one-shots yes
AAM onsets, pitches, instruments, melody instrument, keys, chords, tempo, beats 3000 (artificial) tracks yes
ACM_MIRUM tempo 1410 excerpts (60s) yes
ACPAS aligned audio and scores 2189 performances of 497 scores downloadable
AcousticBrainz-Genre 15-31 genres with 265-745 subgenres audio features for over 2000000 songs no
@Con-Mi
Con-Mi / pytorch041_cuda92_colab.sh
Last active May 31, 2022 05:57
A shell file to install CUDA 9.2 backend for PyTorch 0.4.1 on Google Colab.
#!/bin/bash
TEXT_RESET='\e[0m'
TEXT_YELLOW='\e[1;33m'
wget https://developer.nvidia.com/compute/cuda/9.2/Prod2/local_installers/cuda-repo-ubuntu1604-9-2-local_9.2.148-1_amd64
echo -e $TEXT_YELLOW
echo 'WEBGET finished..'
echo -e $TEXT_RESET
@Dref360
Dref360 / coordconv2d.py
Last active February 11, 2020 14:40
Un-scaled version of CoordConv2D
import keras.backend as K
import tensorflow as tf
from tensorflow.keras.layers import Layer
"""Not tested, I'll play around with GANs soon with it."""
from tensorflow.keras.layers import Conv2D
import numpy as np
class CoordConv2D(Layer):
@gcusso
gcusso / CoordConvLayer.py
Last active August 8, 2021 04:14
Extracted CordConvs tensorflow implementation from (An intriguing failing of convolutional neural networks and the CoordConv solution) https://arxiv.org/pdf/1807.03247.pdf
from tensorflow.python.layers import base
import tensorflow as tf
class AddCoords(base.Layer):
"""Add coords to a tensor"""
def __init__(self, x_dim=64, y_dim=64, with_r=False):
super(AddCoords, self).__init__()
self.x_dim = x_dim
self.y_dim = y_dim