This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from torch import nn | |
from torch.autograd import Function | |
from torch.nn import functional as F | |
class BackwardGradNormFn(Function): | |
""" | |
A normalization layer that does nothing to the input, but | |
normalize the gradient. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Hourglass network, the backbone part. | |
Implemented according to the CornetNet paper. The ArXiv version does not have the backbone description. | |
Reference: | |
- https://link.springer.com/article/10.1007/s11263-019-01204-1 | |
- https://sci-hub.se/https://link.springer.com/article/10.1007/s11263-019-01204-1 (I won't use 40EUR much money *just* to read a paper. Where I live one can buy 10 books with that.) | |
- https://arxiv.org/abs/1808.01244 (not really related to this implementation, just in case someone is curious about CornetNet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Global packages to be installed in home directory | |
# Desktop apps | |
gdown | |
https://github.com/thenaterhood/gscreenshot/archive/refs/tags/v3.4.1.tar.gz | |
# Installed out of convenience | |
fastapi | |
uvicorn | |
pydantic>=2 | |
lenses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Install venv first. | |
apppkg="$1" | |
appcmd="$2" | |
if [ -z "$apppkg" ]; then | |
echo "./mvenvapp.sh <apppkg> [appcmd]" | |
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import pickle | |
import json | |
import sys | |
from os import path, makedirs | |
from io import BytesIO | |
from argparse import ArgumentParser | |
from PIL import Image | |
from lmds import GeneratorModule, create_lmds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from argparse import ArgumentParser | |
from subprocess import Popen | |
# docker run -p 9993:80 -v ./:/usr/share/nginx/html/ nginx:stable-alpine3.17-slim | |
# docker run -v ./:/tmp jrottenberg/ffmpeg:snapshot-alpine -i "rtsp://..." -c copy -hls_time 2 -hls_wrap 10 "/tmp/stream.m3u8" | |
def main(): | |
parser = ArgumentParser() | |
parser.add_argument("--port", "-p", type=int) | |
parser.add_argument("--rtsp", "-i", required=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ -z "$1" ]; then | |
echo "slugifile <file name> [.ext]" | |
fi | |
bn=$(basename "$1" "$2") | |
slug=$(echo "$bn" | iconv -t ascii//TRANSLIT | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | tr A-Z a-z) | |
if [ -z "$2" ]; then | |
echo "$slug" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\newcommand{\Image}[1]{% | |
\sbox0{\includegraphics[height=0.65\paperheight]{#1}}% | |
\ifdim\wd0 < \textwidth | |
\includegraphics[height=0.65\paperheight]{#1}% | |
\else | |
\includegraphics[width=\textwidth]{#1}% | |
\fi% | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Reference https://askubuntu.com/questions/1019530/chinese-fonts-are-not-visible-in-programs-installed-in-wine | |
# | |
# Content of the .reg file just in case | |
# | |
# REGEDIT4 | |
# | |
# [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# https://askubuntu.com/questions/1167283/l2tp-connection-client-on-ubuntu-18-04-server | |
VPNDATA=" | |
gateway = [ipv4], | |
ipsec-enabled = yes, | |
ipsec-psk = 0s"$(base64 <<<'[PSK]' | rev | cut -c2- | rev)"=, | |
mru = 1400, | |
mtu = 1400, | |
password-flags = 0, | |
refuse-chap = yes, |
NewerOlder