Skip to content

Instantly share code, notes, and snippets.

View tfzhou's full-sized avatar
🏠
I may be slow to respond.

Tianfei Zhou tfzhou

🏠
I may be slow to respond.
View GitHub Profile
@tfzhou
tfzhou / pad_packed_demo.py
Created April 21, 2019 10:26 — forked from Tushar-N/pad_packed_demo.py
How to use pad_packed_sequence in pytorch
import torch
import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
seqs = ['gigantic_string','tiny_str','medium_str']
# make <pad> idx 0
vocab = ['<pad>'] + sorted(set(''.join(seqs)))
# make model

MobileNet Inference Time

Movidius NCS Accelerator

Using NCSDK 1.12.00, lastest as of April 2018

Version Average Inference Time
@tfzhou
tfzhou / resnet.py
Created April 13, 2018 07:33 — forked from kyamagu/resnet.py
Caffe NetSpec for ResNet architecture
#!/usr/bin/env python
'''Caffe ResNet NetSpec example.
Compatible with Kaiming He's pre-trained models.
https://github.com/KaimingHe/deep-residual-networks
'''
import sys
@tfzhou
tfzhou / caffe.cpp.md
Last active March 29, 2018 06:06
notes

Learn the register macro used in caffe.cpp

#include <iostream>                                                                                                                                                                                          
 #include <map>                                                                                                                                                                                               
 #include <string>                                                                                                                                                                                            
                                                                                                                                                                                                              
 using namespace std;                                                                                                                            

How to create a custom Caffe layer in Python?

This tutorial will guide through the steps to create a simple custom layer for Caffe using python. By the end of it, there are some examples of custom layers.

- Why would I want to do that?

Usually you would create a custom layer to implement a funcionality that isn't available in Caffe, tuning it for your requirements.

- What will I need?

Probably just Python and Caffe instaled.

- Is there any downside?

void CVMatToDatum(const cv::Mat& cv_img, Datum* datum, int depth)
{
if (depth == CV_8U) {
CVMatToDatum(cv_img, datum);
return;
}
CHECK(cv_img.depth() == CV_32F) << "data type must be 32bit float";
datum->set_channels(cv_img.channels());
@tfzhou
tfzhou / poisson.cpp
Created August 11, 2017 05:31 — forked from thorikawa/poisson.cpp
Poisson Image Editing OpenCV
#include <opencv2/opencv.hpp>
#include <iostream>
#include <vector>
#include <cmath>
#include <assert.h>
using namespace std;
using namespace cv;
@tfzhou
tfzhou / readme.md
Created December 10, 2016 05:16 — forked from baraldilorenzo/readme.md
VGG-16 pre-trained model for Keras

##VGG16 model for Keras

This is the Keras model of the 16-layer network used by the VGG team in the ILSVRC-2014 competition.

It has been obtained by directly converting the Caffe model provived by the authors.

Details about the network architecture can be found in the following arXiv paper:

Very Deep Convolutional Networks for Large-Scale Image Recognition

K. Simonyan, A. Zisserman

@tfzhou
tfzhou / jupyter_shortcuts.md
Created November 30, 2016 15:51 — forked from kidpixo/jupyter_shortcuts.md
Keyboard shortcuts for ipython notebook 3.1.0 / jupyter

Toc

Keyboard shortcuts

The IPython Notebook has two different keyboard input modes. Edit mode allows you to type code/text into a cell and is indicated by a green cell border. Command mode binds the keyboard to notebook level actions and is indicated by a grey cell border.

MacOS modifier keys:

  • ⌘ : Command