Skip to content

Instantly share code, notes, and snippets.

@adgaudio
adgaudio / tesseract_git_install.sh
Created February 21, 2018 21:31
Install tesseract and leptonica from source
#!/usr/bin/env bash
# This script installs leptonica and tesseract from source
# it does not install other pre-requisites to a custom location.
# side note: install prefix is defined once per library.
# side note: it clones git repositories in the current directory.
set -e
set -u
@adgaudio
adgaudio / download_all_pretrained_pytorch_models.ipy
Created August 15, 2019 21:29
A quick hack script that uses ipython to download all pretrained pytorch models
# this is a quick ipython script to download all pre-trained pytorch models.
# run like this:
# ipython THIS_SCRIPT.ipy
import torchvision as tv, types, os.path
# get list of urls ... in a brittle way.
x = {k: v for dct in [getattr(y, 'model_urls') for y in (getattr(tv.models, x) for x in dir(tv.models)) if isinstance(y, types.ModuleType)] for k, v in dct.items()}
@adgaudio
adgaudio / guided_filter_nd.py
Created March 17, 2021 10:18
Guided Filter supporting multi-channel guide image and 1 channel source image
"""
PyTorch Guided Filter for multi-channel (color) guide image and 1 channel
(grayscale) source image
"""
import torch as T
import torch.nn as nn
def box_filter_1d(tensor, dim, r):
cs = tensor.cumsum(dim).transpose(dim, 0)