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
""" | |
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) |
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
# 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()} |
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
// these double forward slashes are comments. you can write whatever you | |
// want in the text after the double slashes. | |
x = 10; | |
y = 20; | |
z = 5; | |
cube([x,y,z], center=true); | |
cube([x,y,z], center=false); |
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
#!/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 |
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 java.util.HashMap; | |
/* A weighted counter that remembers most frequent and recent pairs on a 2-color graph, where: | |
* - any pair (a_i, b_i) contains elements a_i from set A and elements b_i are from set B. A and B are disjoint. | |
* | |
* This counter basically implements a recurrence relation to maintain scores for each pair: | |
* score = memory * prev_score + (1-memory) * (+/-)1 | |
* | |
* "memory" is a value between 0 and 1 chooses how much history history to take into account. | |
* |
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
""" | |
This gist demonstrates that spark 1.0.0 and 0.9.1 | |
don't serialize a logger instance properly when code runs on workers. | |
run this code via: | |
spark-submit spark_serialization_demo.py | |
- or - | |
pyspark spark_serialization_demo.py | |
""" | |
import pyspark |
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
"""SSH tunnel through a gateway to another machine. | |
USAGE: | |
python ./ssh_tunnel.py -h | |
or | |
>>> import ssh_tunnel | |
>>> ssh_tunnel.main('gateway_username', 'dest_host_addr') |
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
""" | |
Based on https://gist.github.com/robbyt/2493423 | |
This StarCluster plugin grants all tcp, udp and icmp privileges for 10.0.0.0/8 | |
between the current cluster's security group and the given security group, | |
in both directions | |
""" | |
from starcluster.clustersetup import ClusterSetup | |
from starcluster.logger import log |
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
# Tmux Configuration | |
# By Alex Gaudio | |
# April 15, 2012 | |
# HACKS | |
####### | |
####### | |
## Unfortunately, the osx system clipboard integration sucks. But there's a well documented workaround. | |
# OS X: pbcopy and pbpaste workaround from ChrisJohnsen | |
# code available at: https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard.git |
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
""" | |
This example demonstrates a distributed algorithm to identify the | |
percentile of a distributed data set. | |
Because this is a toy implementation, the data isn't actually | |
distributed across multiple machines. | |
""" | |
import numpy as np | |
NewerOlder