Skip to content

Instantly share code, notes, and snippets.

@zhreshold
zhreshold / scanner.sh
Created November 15, 2018 07:28 — forked from andyrbell/scanner.sh
Make a pdf look scanned using ImageMagick
# use ImageMagick convert
# the order is important. the density argument applies to input.pdf and resize and rotate to output.pdf
convert -density 90 input.pdf -rotate 0.5 -attenuate 0.2 +noise Multiplicative -colorspace Gray output.pdf
@zhreshold
zhreshold / README.md
Created September 14, 2018 00:01
GluonCV C++ inference prebuilt demos
Platform Download link
Linux(cpu, openblas)1
Linux(gpu, cuda9.0)13
Linux(gpu, cuda9.2)13
Windows x64(cpu, openblas)
Windows x64(gpu, cuda9.2)3
Mac OS(cpu, appleblas)2 x

1: use LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. gluoncv-detect in case you are using the supplied shared libraries under the same directory. You can add export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/path/to/prebuilt-package to ~/.bashrc to permanently add library into search path.

@zhreshold
zhreshold / finetune.md
Last active August 20, 2018 18:42
GluonCV finetune detection models

How to finetune detection models in GluonCV

How to modify pre-trained network from VOC/COCO to custom classes

# python3 train_ssd.py --finetune ssd_300_vgg16_atrous_coco --dataset customxx
import gluoncv as gcv
# download pretrained from coco
net = gcv.model_zoo.get_model('ssd_300_vgg16_atrous_coco', pretrained=True)
# modify network to fit the new classes, say ['a', 'b', 'c']
@zhreshold
zhreshold / bench_ssd.py
Last active July 17, 2018 18:43
GluonCV SSD benchmark
import argparse
import os
import time
import mxnet as mx
import gluoncv as gcv
from gluoncv.data.transforms import presets
def parse_args():
parser = argparse.ArgumentParser(description='Benchmark GluonCV SSD networks.')
parser.add_argument('--network', type=str, default='ssd_300_vgg16_atrous_voc',
@zhreshold
zhreshold / darknet.py
Last active June 26, 2018 01:52
GluonCV Darknet 19
class Darknet(gluon.HybridBlock):
def __init__(self, spec, classes=1000, batch_norm=True, **kwargs):
super(Darknet, self).__init__(**kwargs)
filters = spec['filters']
kernels = spec['kernels']
with self.name_scope():
self.features = nn.HybridSequential()
first_stage = True
for sf, sk in zip(filters, kernels):
if not first_stage:
@zhreshold
zhreshold / test.py
Created June 5, 2018 18:05
NDArray shared mem
import mxnet as mx
from mxnet import nd
data = mx.nd.array([1,2,3], ctx=mx.Context('cpu_shared', 0))
pid, fd, shape, dtype = data._to_shared_mem()
new_data = mx.nd.NDArray(nd.ndarray._new_from_shared_mem(pid, fd, shape, dtype))
print(new_data)
@zhreshold
zhreshold / data_bench.py
Last active May 4, 2018 17:50
Debug DataLoaderIter
from gluoncv.data import imagenet
from mxnet.gluon.data.vision import transforms
from mxnet import gluon
import mxnet as mx
import time
import logging
logging.basicConfig(level=logging.DEBUG)
batch_size = 128
num_workers = 2
@zhreshold
zhreshold / resnet18.prototxt
Last active July 11, 2019 06:38
ResNet18 prototxt
name: "ResNet-18"
input: "data"
input_dim: 1
input_dim: 3
input_dim: 224
input_dim: 224
layer {
bottom: "data"
top: "conv1"
@zhreshold
zhreshold / parallel18_6x_CIFAR10.prototxt
Last active March 1, 2018 20:13
parallel18_6x_CIFAR10 prototxt
name: "Parallel18_6x_CIFAR10"
layer {
name: "data"
type: "Input"
top: "data"
input_param {
shape {
dim: 1
dim: 3
dim: 32
@zhreshold
zhreshold / prepare_val.sh
Created January 30, 2018 17:28
Prepare val data for ILSVRC2012
This file has been truncated, but you can view the full file.
mkdir -p n01440764
mkdir -p n01443537
mkdir -p n01484850
mkdir -p n01491361
mkdir -p n01494475
mkdir -p n01496331
mkdir -p n01498041
mkdir -p n01514668
mkdir -p n01514859
mkdir -p n01518878