Skip to content

Instantly share code, notes, and snippets.

@akii-i
akii-i / lora_convert.py
Last active July 18, 2023 19:13
LORA format conversion from cloneofsimo lora format to AUTOMATIC1111 webui format (kohya's format)
# Convert cloneofsimo lora format to AUTOMATIC1111 webui format (kohya's format)
# Will generate extra embedding files along with the converted lora
# Usage: python lora_convert.py path_to_lora output_folder [--overwrite]
# path_to_lora_file : path to lora safetensors in cloneofsimo lora format
# output_folder : path to folder for results in AUTOMATIC1111 webui format
# overwrite : overwrite the results in output_folder
# Example: python lora_convert.py .\lora_krk.safetensors .\
from safetensors import safe_open
from safetensors.torch import save_file
@aormorningstar
aormorningstar / rotation.py
Last active January 12, 2024 21:24
Find the rotation matrix that aligns one three-dimensional vector with another.
import numpy as np
def rotation(v1, v2):
"""
Compute a matrix R that rotates v1 to align with v2.
v1 and v2 must be length-3 1d numpy arrays.
"""
# unit vectors
u = v1 / np.linalg.norm(v1)
Ru = v2 / np.linalg.norm(v2)
@Mr4k
Mr4k / differentialdithering.ipynb
Created September 9, 2020 02:32
DifferentialDithering.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# git clone https://github.com/NVlabs/stylegan2
import os
import numpy as np
from scipy.interpolate import interp1d
from scipy.io import wavfile
import matplotlib.pyplot as plt
import PIL.Image
import moviepy.editor
import dnnlib
@vadimkantorov
vadimkantorov / perlin.py
Last active February 15, 2024 10:36
Perlin noise in PyTorch
# ported from https://github.com/pvigier/perlin-numpy/blob/master/perlin2d.py
import torch
import math
def rand_perlin_2d(shape, res, fade = lambda t: 6*t**5 - 15*t**4 + 10*t**3):
delta = (res[0] / shape[0], res[1] / shape[1])
d = (shape[0] // res[0], shape[1] // res[1])
grid = torch.stack(torch.meshgrid(torch.arange(0, res[0], delta[0]), torch.arange(0, res[1], delta[1])), dim = -1) % 1
@jcreinhold
jcreinhold / rpca_gpu.py
Last active February 7, 2024 04:10
GPU RPCA and SVT
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
rpca_gpu
implementations of RPCA on the GPU (leveraging pytorch)
for low-rank and sparse matrix decomposition as well as
a nuclear-norm minimization routine via singular value
thresholding for matrix completion
@hlorand
hlorand / vidstab_ffmpeg.md
Last active June 22, 2024 19:07
Video stabilization using VidStab and FFMPEG

Video stabilization using VidStab and FFMPEG

** Step 1 **

Install ffmpeg with the vidstab plugin.

@Kaixhin
Kaixhin / transformer.py
Created April 7, 2018 21:34
The Annotated Transformer
"""
The Annotated Transformer
http://nlp.seas.harvard.edu/2018/04/03/attention.html
Note: Only includes basic example, not real world example or multi-GPU training
"""
import numpy as np
import torch
import torch.nn as nn
/**
* [TF2] Jungle Inferno Equipment
*/
#pragma semicolon 1
#include <sourcemod>
#include <tf2_stocks>
#include <clientprefs>
#include <sdkhooks>
@aaronpolhamus
aaronpolhamus / map_clsloc.txt
Created May 12, 2016 01:21
Image net classes + labels
n02119789 1 kit_fox
n02100735 2 English_setter
n02110185 3 Siberian_husky
n02096294 4 Australian_terrier
n02102040 5 English_springer
n02066245 6 grey_whale
n02509815 7 lesser_panda
n02124075 8 Egyptian_cat
n02417914 9 ibex
n02123394 10 Persian_cat