Skip to content

Instantly share code, notes, and snippets.

@recoilme
recoilme / SSD-1B.ipynb
Last active October 26, 2023 20:11
SSD-1B 1st look
View SSD-1B.ipynb
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
View 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
View img.py
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
View merge.py
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
View weightedsim.py
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
View server.go
package main
import (
"fmt"
"net/http"
"github.com/recoilme/clean"
. "github.com/stevelacy/daz"
)
View gist:5eff4c28c9b2b982c08e2621deb81d68
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
View hash_test.go
package main_test
import (
"strconv"
"testing"
"github.com/cespare/xxhash"
"github.com/spaolacci/murmur3"
)
View vowpal_wabbit_in_daemon.go
package main
import (
"bufio"
"fmt"
"log"
"net"
)
// mac: brew install vowpal-wabbit
View server.go
package main
import (
"fmt"
"net/http"
"strings"
"time"
)
// Server is a HTTP interface