Skip to content

Instantly share code, notes, and snippets.

View NTU-P04922004's full-sized avatar
🏍️
Life in a fast line

Kuo-Hsin Tu NTU-P04922004

🏍️
Life in a fast line
  • Taipei, Taiwan
View GitHub Profile
@NTU-P04922004
NTU-P04922004 / docker_cheat.sh
Last active July 16, 2021 06:43
Docker cheatsheet
# References:
# https://github.com/NVIDIA/nvidia-docker#usage
# http://peterforgacs.github.io/2017/04/18/Docker-basics/
#
docker run --gpus '"device=1"' -it --rm -v /home/kuohsin/workspace/tensorrt_lab/torch2trt:/workspace tensorrt
docker container ls -a
docker container rm container_id
sudo docker commit container_id image_name
@NTU-P04922004
NTU-P04922004 / gist:5d1731363f0a6ef964bf9abedad39d55
Created December 11, 2019 09:28
ffmpeg extracts video frames
# Output one image every second, named out1.png, out2.png, out3.png, etc.
# The %01d dictates that the ordinal number of each output image will be formatted using 1 digits.
ffmpeg -i input.mov -vf fps=1 out%d.png
@NTU-P04922004
NTU-P04922004 / torch_summary.md
Created November 30, 2019 12:04
Model summary in PyTorch

pip install torchsummary or git clone https://github.com/sksq96/pytorch-summary

from torchsummary import summary
summary(your_model, input_size=(channels, H, W))
@NTU-P04922004
NTU-P04922004 / tf_slim_lab.py
Created November 24, 2019 13:19
Analyze TF model with tf-slim
import tensorflow.contrib.slim as slim
model_vars = tf.trainable_variables()
slim.model_analyzer.analyze_vars(model_vars, print_info=True)
slim.model_analyzer.analyze_ops(tf.compat.v1.get_default_graph(), print_info=True)
keys = list(finger_label_dict.keys())
keys.sort(key=lambda f: int(''.join(filter(str.isdigit, f))))
import sys
import json
import os
import numpy as np
import cv2
def get_out_filename(input_path):
dir_path = os.path.dirname(input_path)
dir_name = os.path.basename(dir_path)
out_path = dir_name + '_label.txt'
"""
"""
import os
import cv2
IMAGE_WIDTH = 640
IMAGE_HEIGHT = 480
@NTU-P04922004
NTU-P04922004 / crop_drawing_hands.py
Created June 28, 2018 08:36
parse and crop image in python
import sys
import json
import os
import numpy as np
import cv2
def get_out_filename(input_path):
dir_path = os.path.dirname(input_path)
dir_name = os.path.basename(dir_path)
out_path = dir_name + '_label.txt'
name: "CIFAR10_BN"
layer {
name: "data"
type: "Input"
top: "data"
input_param { shape: { dim: 1 dim: 3 dim: 32 dim: 32 } }
}
layer {
name: "conv1"
type: "Convolution"
{
"layer": [
{
"name":"ip1",
"input":[
"data"],
"output":[
"ip1"],
"weight":[
"ip1_0",