Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
"""
Analyze per-layer compute (MACs) of an ONNX model by joining onnx_tool's
per-node MACs data with semantic layer names derived from weight initializers.
Usage:
python analyze_macs.py --onnx model.onnx
python analyze_macs.py --onnx model.onnx --input-shapes images:1x3x750x1333
Dependencies: onnx, numpy, onnx_tool

spaCy 日语 Transformer 模型安装流程

适用于需要加载 ja_core_news_trf 的 conda 环境。

安装

conda create -n ner_exp python=3.14
conda activate ner_exp
@ak64th
ak64th / gst_wallclock_aligned_recorder.py
Last active August 28, 2026 11:26
MP4 recorder with gstreamer splitmux sink
#!/usr/bin/env python3
"""A demo of a wall-clock-aligned, crash-resilient MP4 recorder.
Run this example with:
python3 gst_wallclock_aligned_recorder.py --interval 10 \
--outdir /tmp/rot
The following pipeline is similar, but is not equivalent:
```
@ak64th
ak64th / two_hops.go
Last active August 13, 2026 10:09
Tow hops ssh forward
package main
import (
"bytes"
"crypto/ed25519"
"crypto/rand"
"crypto/x509"
"encoding/pem"
"fmt"
"io"
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst
NAL_BREAKER = b'\x00\x00\x00\x01'
def rtspsrc_pad_added(element, pad, target):
caps = pad.query_caps(None).to_string()
@ak64th
ak64th / gstreamer_rtsp_to_mp4.py
Last active September 29, 2026 08:33
Save rtsp video stream data into a .mp4 file without sounds, re-encoding with libx264.
import sys
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst
Gst.init(None)
RTSP_VIDEO = Gst.Caps.from_string('application/x-rtp, media=(string)video')
@ak64th
ak64th / train_with_imgaug.py
Created September 29, 2021 04:03
Use imgaug with detectron2
import argparse
import copy
import os
import pathlib
from datetime import datetime
import imgaug.augmenters as iaa
import imgaug.random as ia_random
import numpy as np
import torch
@ak64th
ak64th / htpasswd.py
Created September 14, 2021 07:08 — forked from eculver/htpasswd.py
htpasswd script in python (no need to install apache utils)
#!/usr/local/bin/python
"""Replacement for htpasswd"""
# Original author: Eli Carter
import os
import sys
import random
from optparse import OptionParser
# We need a crypt module, but Windows doesn't have one by default. Try to find
@ak64th
ak64th / config.dev.toml
Last active June 30, 2021 08:38
Settings deserialization for python: pydantic vs attrs+cattrs
secret_key = "3EEeX_v1exDXdE79CbLVDpQB4F1dmxm2cOC0eQB7Q1k="
[hops.aliyun]
ip = "112.112.112.2"
username = "kingo"
[hops.pi]
ip = "10.10.100.2"
username = "pi"
@ak64th
ak64th / mqtt_monitor.py
Last active January 9, 2020 10:00
Use hbmqtt with prompt_toolkit
import asyncio
import logging
from hbmqtt.client import MQTTClient, ClientException
from hbmqtt.mqtt.constants import QOS_0
from prompt_toolkit.application import Application
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.layout import Layout
from prompt_toolkit.widgets import Frame, TextArea
from natsort import natsorted