Skip to content

Instantly share code, notes, and snippets.

View jkjung-avt's full-sized avatar

JK Jung jkjung-avt

View GitHub Profile
jkjung-avt /
Created October 12, 2021 09:23
Example code for handling TensorRT INT8 calibration file
from pathlib import Path
import struct
lines = Path('calib_yolov4-int8-608.bin').read_text().splitlines()
for line in lines:
pair = line.split(':')
if len(pair) != 2:
assert len(pair[1]) == 9
bstr = bytes.fromhex(pair[1][1:]) # convert to byte string
jkjung-avt /
Last active October 19, 2023 13:58
Scripts for installing tensorflow-2.6.0 on JetPack-4.6
set -e
# tensorflow version
if [[ ! $(head -1 /etc/nv_tegra_release) =~ R32.*6\.1 ]] ; then
echo "ERROR: not JetPack-4.6"
exit 1
jkjung-avt /
Last active July 18, 2022 09:10
從公開資訊觀測站下載108年度台灣上市、上櫃公司 "非擔任主管職務之全時員工薪資資訊"
For crawling average salaries of all public listed companies on Taiwan
Stock Exchange. Data source:
Source code reference:
$ python3
jkjung-avt /
Last active August 20, 2021 08:04
Scripts for building/installing opencv, pytorch, and tensorflow on my Ubuntu-18.04 x86_64 PC
# Reference:
# I have a GTX-1080 and a GTX-2080 Ti, thus CUDA_ARCH "6.1" and "7.5".
# Patch cmake if necessary:
git clone pytorch-v1.3.1
cd pytorch-v1.3.1
git checkout v1.3.1
git submodule update --init --recursive
jkjung-avt /
Last active April 5, 2020 11:37
I practiced coding a maze generator with the Disjoint Set data structure
import random
class DisjointSet(object):
jkjung-avt /
Last active August 29, 2022 08:21
Script to convert a nv-caffe saved caffemodel file into another file which could be read by bvlc-caffe
1. compile the nv-caffe's caffe.proto to
2. use to convert the nv-caffe caffemodel file
into bvlc-caffe compatible format.
Example usage:
$ cd ${HOME}/project/nv-caffe
$ protoc src/caffe/proto/caffe.proto --python_out=.
$ python3 ./ <in.caffemodel> <out.caffemodel>
jkjung-avt /
Created October 28, 2018 09:44
A simple DCGAN with MNIST
This script was orginally written by Rowel Atienza (see below), and
was modified by JK Jung <>.
DCGAN on MNIST using Keras
Author: Rowel Atienza
jkjung-avt /
Created September 29, 2018 06:35
Example command to initiate a GCP ML training job
# export YOUR_GCS_BUCKET=oxford-iiit-pets-dataset
gcloud ml-engine jobs submit training `whoami`_object_detection_pets_`date +%m_%d_%Y_%H_%M_%S` \
--runtime-version 1.9 \
--job-dir=gs://${YOUR_GCS_BUCKET}/model_dir \
--packages /home/jkjung/src/tensorflow/models/research/dist/object_detection-0.1.tar.gz,/home/jkjung/src/tensorflow/models/research/slim/dist/slim-0.1.tar.gz,/tmp/pycocotools/pycocotools-2.0.tar.gz \
--module-name object_detection.model_main \
--region asia-east1 \
--config cloud-ssd_mobilenet_v1_pets.yml \
-- \
jkjung-avt /
Created August 31, 2018 12:14
An example multiprocessing-ready data generator for Keras, taken from
import numpy as np
import keras
class DataGenerator(keras.utils.Sequence):
'Generates data for Keras'
def __init__(self, list_IDs, labels, batch_size=32, dim=(32,32,32), n_channels=1,
n_classes=10, shuffle=True):
self.dim = dim
self.batch_size = batch_size
jkjung-avt /
Last active June 20, 2023 15:11 — forked from ck196/
Capture live video from camera and do Single-Shot Multibox Detector (SSD) object detetion in Caffe on Jetson TX2/TX1.
# --------------------------------------------------------
# Camera Single-Shot Multibox Detector (SSD) sample code
# for Tegra X2/X1
# This program captures and displays video from IP CAM,
# USB webcam, or the Tegra onboard camera, and do real-time
# object detection with Single-Shot Multibox Detector (SSD)
# in Caffe. Refer to the following blog post for how to set
# up and run the code: