Skip to content

Instantly share code, notes, and snippets.

View green-s's full-sized avatar

Sam Green green-s

View GitHub Profile
@Pytness
Pytness / copilot_proxy.py
Created February 2, 2023 09:33
A proxy for copilot labs. pip install rich
#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
import json
from http.server import BaseHTTPRequestHandler, HTTPServer
import requests
# 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
@lmmx
lmmx / diarise.py
Last active November 7, 2023 21:37
Python commands to create speaker diarisation
# ffmpeg -i foo.m4a foo.wav
from pyannote.audio import Pipeline
pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization")
diarization = pipeline("foo.wav")
# RTTM format https://catalog.ldc.upenn.edu/docs/LDC2004T12/RTTM-format-v13.pdf
with open("foo.rttm", "w") as rttm:
diarization.write_rttm(rttm)
@amishmm
amishmm / ArchOracleCloud.md
Last active April 24, 2024 11:00
Install Arch Linux on Oracle Cloud (Free Tier)

Requirement

  • Console / Cloud Shell access (via https://cloud.oracle.com)
  • Go to the instance page and under Resources -> Console connection -> Launch Cloud Shell connection

Steps

  1. In Ubuntu OR any other Free tier Linux OS
# Download Alpine Linux and install it on disk
cd /
wget https://dl-cdn.alpinelinux.org/alpine/v3.16/releases/x86_64/alpine-virt-3.16.2-x86_64.iso
@trygvebw
trygvebw / generate.py
Last active July 29, 2023 20:01
My Stable Diffusion image generation function. Abbreviated – will not run because of a few missing utility functions and classes.
def normalize_latent(x, max_val, quantile_val):
x = x.detach().clone()
for i in range(x.shape[0]):
if x[[i], :].std() > 1.0:
x[[i], :] = x[[i], :] / x[[i], :].std()
s = torch.quantile(torch.abs(x[[i], :]), quantile_val)
s = torch.maximum(s, torch.ones_like(s) * max_val)
x[[i], :] = x[[i], :] / (s / max_val)
return x
@harishanand95
harishanand95 / Stable_Diffusion.md
Last active June 6, 2024 08:42
Stable Diffusion on AMD GPUs on Windows using DirectML
@karpathy
karpathy / stablediffusionwalk.py
Last active June 10, 2024 18:34
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
/*=============================================================================
ReShade 5 effect file
github.com/martymcmodding
Author: Pascal Gilcher / Marty McFly
ReShade Motion Estimation Shader for dense 2D UV-space motion vectors
Based on ReShade Motion Estimation by Jakob Wapenhensch
(https://github.com/JakobPCoder/ReshadeMotionEstimation)
@str4d
str4d / DemangleRust.py
Last active May 7, 2024 01:40
Ghidra script for demangling Rust symbols
# Attempts to demangle all mangled symbols in the current program using the Rust
# mangling schemes, and replace the default symbol and function signature
# (if applicable) with the demangled symbol.
#
# License: MIT OR Apache-2.0
#@author Jack Grigg <thestr4d@gmail.com>
#@category Symbol
import string
@krzys-h
krzys-h / Hyper-V GPU-PV with Linux guest.md
Last active June 19, 2024 08:15
Ubuntu 21.04 VM with GPU acceleration under Hyper-V...?

Ubuntu 21.04 VM with GPU acceleration under Hyper-V...?

Modern versions of Windows support GPU paravirtualization in Hyper-V with normal consumer graphics cards. This is used e.g. for graphics acceleration in Windows Sandbox, as well as WSLg. In some cases, it may be useful to create a normal VM with GPU acceleration using this feature, but this is not officially supported. People already figured out how to do it with Windows guests though, so why not do the same with Linux? It should be easy given that WSLg is open source and reasonably well documented, right?

Well... not quite. I managed to get it to run... but not well.

How to do it?

  1. Verify driver support