Skip to content

Instantly share code, notes, and snippets.

@lopho
lopho / zram.sh
Created February 5, 2017 17:07 — forked from sultanqasim/zram.sh
ZRAM config for Raspberry Pi 3
#!/bin/bash
# Raspberry Pi ZRAM script
# Tuned for quad core, 1 GB RAM models
# put me in /etc/init.d/zram.sh and make me executable
# then run "sudo update-rc.d zram.sh defaults"
modprobe zram
echo 3 >/sys/devices/virtual/block/zram0/max_comp_streams
echo lz4 >/sys/devices/virtual/block/zram0/comp_algorithm
@lopho
lopho / imagenet1000_clsid_to_human.txt
Created July 10, 2018 01:24 — forked from yrevar/imagenet1000_clsidx_to_labels.txt
text: imagenet 1000 class id to human readable labels (Fox, E., & Guestrin, C. (n.d.). Coursera Machine Learning Specialization.)
{0: 'tench, Tinca tinca',
1: 'goldfish, Carassius auratus',
2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias',
3: 'tiger shark, Galeocerdo cuvieri',
4: 'hammerhead, hammerhead shark',
5: 'electric ray, crampfish, numbfish, torpedo',
6: 'stingray',
7: 'cock',
8: 'hen',
9: 'ostrich, Struthio camelus',
@lopho
lopho / OpenSimplexNoise.cpp
Created February 6, 2021 03:05 — forked from jessestricker/OpenSimplexNoise.cpp
[C++] OpenSimplexNoise
#include "OpenSimplexNoise.hpp"
#include <cmath> // sqrt
#include <numeric> // std::iota
#include <algorithm> // std::shuffle
const OpenSimplexNoise::value_t
OpenSimplexNoise::STRETCH_CONST = (sqrt(3) - 3) / 6,
OpenSimplexNoise::SQUISH_CONST = (sqrt(3) - 1) / 2;
const std::array<OpenSimplexNoise::gradient, 8> OpenSimplexNoise::GRADIENTS =
@lopho
lopho / curl_range.md
Created June 16, 2021 17:05 — forked from mocchira/curl_range.md
HTTP GET with Range header by curl
  • normal(explicitly specified start AND end)
  curl -v -X GET -H "range: bytes=1-8" http://localhost:8080/bbb/test
  • specified ONLY start(end will be specified at the end of file)
  curl -v -X GET -H "range: bytes=10-" http://localhost:8080/bbb/test
  • specified ONLY one negative value(last N bytes of file will be retrieved)
@lopho
lopho / find_noise.py
Created September 12, 2022 09:32 — forked from trygvebw/find_noise.py
A "reverse" version of the k_euler sampler for Stable Diffusion, which finds the noise that will reconstruct the supplied image
import torch
import numpy as np
import k_diffusion as K
from PIL import Image
from torch import autocast
from einops import rearrange, repeat
def pil_img_to_torch(pil_img, half=False):
image = np.array(pil_img).astype(np.float32) / 255.0
# 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