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 / kimi-discord-bot.py
Created February 19, 2024 10:12
kimi-discord-bot.py
import discord
import asyncio
import logging
import logging.handlers
from openai import OpenAI
from discord import app_commands
from discord import Message
KIMITOKEN = ""
DISCORD_BOT_TOKEN = ""
@Mikubill
Mikubill / convnext-v2-train.py
Created November 19, 2023 15:24
ConvNeXt V2 Image Classifier
import os
import random
import math, warnings
from copy import deepcopy
import numpy as np
import lightning
import torch
import torch.nn as nn
import torch.nn.functional as F
@Mikubill
Mikubill / sam-background.ipynb
Last active October 12, 2023 10:31
SAM-Remove-Background
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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
@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 / 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 / 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 / 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 / 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
#!/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)"