Skip to content

Instantly share code, notes, and snippets.

View Mikubill's full-sized avatar
🌴
On vacation

Kakigōri Maker Mikubill

🌴
On vacation
View GitHub Profile
@Mikubill
Mikubill / server.go
Last active March 13, 2023 01:10
Golang Simple HTTP Server
package main
import (
"log"
"net/http"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
@Mikubill
Mikubill / otp.go
Created December 31, 2020 06:18
simple otp module
package otp
import (
"bytes"
"crypto/hmac"
"crypto/sha1"
"encoding/binary"
"strconv"
"strings"
"time"
@Mikubill
Mikubill / init.sh
Last active September 7, 2021 13:00
#!/bin/sh
# This script is meant for quick & easy install via:
# $ curl -fsSL https://gist.github.com/Mikubill/e6bf3877a967e4689066a8fd03c62818/raw/init.sh | bash
#
# For docker support:
# $ curl -fsSL https://gist.github.com/Mikubill/e6bf3877a967e4689066a8fd03c62818/raw/init.sh | bash -s docker
#
# For wireguard support:
# $ curl -fsSL https://gist.github.com/Mikubill/e6bf3877a967e4689066a8fd03c62818/raw/init.sh | bash -s wg
#!/bin/sh
set -e
command_exists() {
command -v "$@" > /dev/null 2>&1
}
user="$(id -un 2>/dev/null || true)"
# username="neko-$(tr -dc 0-9a-f </dev/urandom | head -c 2)"
# original="$(hostname)"
@Mikubill
Mikubill / train_dreambooth.py
Last active December 9, 2022 07:27
Dreambooth / Finetune with aspect ratio bucketing and cosine annealing
'''Simple script to finetune a stable-diffusion model'''
import argparse
import contextlib
import copy
import gc
import hashlib
import itertools
import json
import math
@Mikubill
Mikubill / deepbooru.py
Created November 3, 2022 04:59
Extract tags from image using deepdanbooru (and save to txt)
import os.path
import re
import tempfile
import argparse
import glob
import zipfile
import deepdanbooru as dd
import tensorflow as tf
import numpy as np
@Mikubill
Mikubill / toolformer.py
Last active March 13, 2023 01:10
Simple Toolformer with OpenAI API
import os
import json
import openai
import requests
from copy import deepcopy
from datetime import date
today = date.today()
openai.api_key = ""
@Mikubill
Mikubill / translator.py
Created March 13, 2023 01:09
openai-translator
import os
import openai
import gradio as gr
openai.api_key = os.environ['OPENAI_KEY']
supportLanguages = [
["auto", "auto"],
["粤语", "yue"],
["古文", "wyw"],
@Mikubill
Mikubill / NAFNet.py
Last active November 1, 2023 07:29
Use NAFNet to upscale images in batch.
#
# NAFNet Image Upscaler
# Mikubill, MIT License
#
# Usage:
# python nafnet.py -i [path_to_images]
#
# Parameters:
# -m, --model: Specifies the model to use. The default is NAFNet-REDS-width64.
# -i, --input: Path to the directory containing images to upscale. This parameter is required.
@Mikubill
Mikubill / clip_aesthetic.py
Last active August 30, 2023 14:36
Batch inference for CLIP Aesthetic Score
import sys
import torch
import torch.nn as nn
import torch.nn.functional as F
import clip
import pandas as pd
import hashlib
import numpy
import cv2
from tqdm.auto import tqdm