Skip to content

Instantly share code, notes, and snippets.

@recoilme
recoilme / mp32mp4.ipynb
Last active March 11, 2024 10:10
Convert audio to movement
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@recoilme
recoilme / dataset.json
Created January 30, 2024 17:45
Example train GPT2 for prompts generation
[{"prompt":"An ancient man is riding in a carriage along a mountain road.","txt":"Venerable man journeys in ancient mountains. Carriage creaks, revealing deep wisdom. Twilight paints dreamlike tableau.","_id":"65b7ba0cfb9aff6d419a368e"},
{"prompt":"Great Wall of China","txt":"Ancient wall, setting sun, breathtaking beauty.","_id":"65b7b89ffb9aff6d419a3688"},
{"prompt":"A resident of the mountains is riding in a carriage along a rocky road","txt":"Mountaineer finds solace in antique carriage, rugged path of rocks, rustic charm, creaking wheels, calm resolve, beautiful mountains, untamed road, orange sunset, approaching night.","_id":"65b7b71ffb9aff6d419a3684"},
{"prompt":"A person in primitive clothing traveling on Earth. Their hands hold simple tools reflecting their primitive wisdom. They stand under a breathtaking sunset, painting the sky in beautiful shades. Mountains in the background and a winding river complete the lush landscape. Ancient creatures can be seen in the distance, seemingly unaware of these
@recoilme
recoilme / SSD-1B.ipynb
Last active October 26, 2023 20:11
SSD-1B 1st look
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@recoilme
recoilme / videomaskbyface.py
Last active October 6, 2023 15:00
videomaskbyface.py
import cv2
import os
import time
import mediapipe as mp
import numpy as np
def extract_faces(image):
center_faces = []
BaseOptions = mp.tasks.BaseOptions
FaceDetector = mp.tasks.vision.FaceDetector
@recoilme
recoilme / img.py
Created October 2, 2023 08:57
Create mask from image based on face coords
import cv2
import numpy as np
import dlib
import mediapipe as mp
import argparse
import torch
from diffusers import StableDiffusionImg2ImgPipeline
from diffusers import EulerAncestralDiscreteScheduler
from typing import Any, Callable, Dict, List, Optional, Union
import PIL
import torch
from typing import Tuple, Callable
def do_nothing(x: torch.Tensor, mode:str=None):
return x
def mps_gather_workaround(input, dim, index):
if input.shape[-1] == 1:
@recoilme
recoilme / weightedsim.py
Created February 19, 2023 18:01
Cosine similarity merging
import os
import argparse
import torch
import numpy as np
from tqdm import tqdm
parser = argparse.ArgumentParser(description="Merge models with weighted similarity")
parser.add_argument("a", type=str, help="Path to model a")
parser.add_argument("b", type=str, help="Path to model b")
parser.add_argument("--out", type=str, help="Output file name, without extension", default="merged", required=False)
@recoilme
recoilme / server.go
Created March 24, 2021 08:45
server for html parsing with readability
package main
import (
"fmt"
"net/http"
"github.com/recoilme/clean"
. "github.com/stevelacy/daz"
)
package main
import (
"bufio"
"log"
"os"
ljpg "github.com/pixiv/go-libjpeg/jpeg"
)
@recoilme
recoilme / hash_test.go
Created February 19, 2021 16:26
Benchmark murmur3(32) and xxHash64
package main_test
import (
"strconv"
"testing"
"github.com/cespare/xxhash"
"github.com/spaolacci/murmur3"
)