Skip to content

Instantly share code, notes, and snippets.

View Sg4Dylan's full-sized avatar
🐱

SgDylan Sg4Dylan

🐱
View GitHub Profile
@Sg4Dylan
Sg4Dylan / ascii2d_batch_match.py
Created July 19, 2020 08:23
使用 Ascii2D 批量匹配可能存在于 Pixiv 的 Twitter 图片
import os
import re
import json
import urllib
import requests
import wget
from tqdm import tqdm
from bs4 import BeautifulSoup
# 执行推理用
import numpy as np
@Sg4Dylan
Sg4Dylan / vmaf_for_image.py
Created June 7, 2020 03:07
使用 VMAF 测量图片质量
import os
import shutil
from PIL import Image
def check_size(image_a, image_b):
global i_size
w_a, h_a = Image.open(image_a).size
w_b, h_b = Image.open(image_b).size
if w_a == w_b and h_a == h_b:
@Sg4Dylan
Sg4Dylan / Lightpack.ino
Created June 6, 2020 03:22
Lightpack 开源破车
/*
* Arduino interface for the use of WS2812 strip LEDs
* Uses Adalight protocol and is compatible with Boblight, Prismatik etc...
* "Magic Word" for synchronisation is 'Ada' followed by LED High, Low and Checksum
* @author: Wifsimster <wifsimster@gmail.com>
* @library: FastLED v3.001
* @date: 11/22/2015
*/
#include <FastLED.h>
#define NUM_LEDS 50 // 设置灯珠总数(貌似不能超过 400 个
@Sg4Dylan
Sg4Dylan / opti.py
Last active November 24, 2020 06:50
Export ESRGAN model to ONNX format
import onnx
import onnxoptimizer as optimizer
onnxfile = 'ONNX_FILE_NAME'
onnx_model = onnx.load(f'{onnxfile}.onnx')
inputs = onnx_model.graph.input
name_to_input = {}
for input in inputs:
name_to_input[input.name] = input
@Sg4Dylan
Sg4Dylan / convert_model.bat
Created May 8, 2020 01:24
优化 PyTorch 输出 ONNX 模型并转换为 NCNN 模型
@ECHO OFF & CD/D "%~dp0"
::save as CRLF/ANSI format
::usage: drag ONNX model to .bat to start processing
:start
IF "%~1"=="" GOTO :END
:proc
python -m onnxsim "%~nx1" "%~nx1.sim.onnx"
@Sg4Dylan
Sg4Dylan / gfwlist2unbound.py
Created May 8, 2020 01:19
将 gfwlist 转换为 Unbound 的 forward-zone 格式
# -*- coding:utf-8 -*-
"""
Convert https://raw.githubusercontent.com/petronny/gfwlist2pac/master/gfwlist.pac for unbound.
"""
import re
with open("gfwlist.conf", 'w') as wp:
for line in open("gfwlist.pac"):
@Sg4Dylan
Sg4Dylan / regnet.ipynb
Created May 8, 2020 01:14
RegNet 模型使用/导出ONNX - Colab 版本
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Sg4Dylan
Sg4Dylan / BH1750_CTL.ino
Created June 24, 2019 12:58
显示器亮度自动调节套装
#include <Wire.h>
#include <BH1750.h>
BH1750 lightMeter;
void setup(){
Serial.begin(9600);
// Initialize the I2C bus (BH1750 library doesn't do this automatically)
// On esp8266 devices you can select SCL and SDA pins using Wire.begin(D4, D3);
Wire.begin();
@Sg4Dylan
Sg4Dylan / utorrent_autoban.py
Last active May 6, 2020 23:20
uTorrent 自动屏蔽迅雷
import re
import os
import json
import time
import base64
import requests
ipfilter_path = r'D:\Program Files (x86)\uTorrent\ipfilter.dat' # ipfilter.dat 路径
remote_url = 'http://127.0.0.1:23333/gui/' # uTorrent 使用的 WebUI 地址
username = b'admin' # WebUI 使用的用户名
@Sg4Dylan
Sg4Dylan / EhTagTranslatorWrapper.py
Created January 5, 2019 04:10
E绅士翻译注射器💉Wiki 解析实现
'''
E绅士翻译注射器💉Wiki 解析实现
直接用 EhTagBuilder 就能拿到 JSON 格式的数据库
本脚本是为方便集成做的简易版解析实现
参考了 EhTagTranslator 的实现过程
'''
import re
import json
import requests