Skip to content

Instantly share code, notes, and snippets.

@yongjun823
yongjun823 / csv_concat.py
Created November 17, 2018 06:22
python csv concat open image style
import os
CSV_FOLDER = 'csvs/'
def parse_csv(csv_path):
arr = []
csv_arr = open(csv_path, encoding='utf-8')
next(csv_arr)
for i in csv_arr:
@yongjun823
yongjun823 / arr.cpp
Created November 9, 2018 09:14
c++ template with class
/////
#include <iostream>
#include "arr.h"
template class Arrayy<int>;
template class Arrayy<double>;
template <typename T>
Arrayy<T>::Arrayy() {
@yongjun823
yongjun823 / restart.sh
Created October 28, 2018 02:40
hyperledger composer restart
./fabric-scripts/hlfv11/stopFabric.sh
./fabric-scripts/hlfv11/teardownFabric.sh
./fabric-scripts/hlfv11/startFabric.sh
composer card delete --card admin@ttcnetwork
composer archive create --sourceType dir --sourceName . -a ./dist/ttc-network.bna
composer network install --card PeerAdmin@hlfv1 --archiveFile ./dist/ttc-network.bna
sudo apt-get update
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
sudo apt-get install -y build-essential
sudo npm install -g node-gyp
sudo apt-get install -y python2.7
export PYTHON=/usr/bin/python2.7
sudo chown -R $USER /usr/local
npm uninstall -g composer-cli
@yongjun823
yongjun823 / tpu_mnist.py
Created October 9, 2018 08:19
mnist tpu keras (tensorflow)
import tensorflow as tf
import numpy as np
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.fashion_mnist.load_data()
# add empty color dimension
x_train = np.expand_dims(x_train, -1)
x_test = np.expand_dims(x_test, -1)
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.BatchNormalization(input_shape=x_train.shape[1:]))
model.add(tf.keras.layers.Conv2D(64, (5, 5), padding='same', activation='elu'))
---
################################################################################
#
# Section: Organizations
#
# - This section defines the different organizational identities which will
# be referenced later in the configuration.
#
################################################################################
Organizations:
@yongjun823
yongjun823 / step2.py
Created September 22, 2018 06:19
image slice and augmentation code !! with python
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 20 11:24:50 2017
@author: chs
"""
from joblib import Parallel, delayed
import glob
import os
@yongjun823
yongjun823 / compose.sh
Last active December 10, 2018 09:30
ubuntu docker install script
sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
@yongjun823
yongjun823 / tf_two_session.py
Created August 8, 2018 12:18
tensorflow two session and run run
import tensorflow as tf
import numpy as np
class A:
def __init__(self):
self.X = tf.placeholder(tf.float32, [None, 10])
self.l1 = tf.layers.dense(self.X, 10)
self.sess = tf.Session()
self.sess.run(tf.global_variables_initializer())
@yongjun823
yongjun823 / obj_slice.py
Created July 5, 2018 07:23
obj bbox dataset slice
from PIL import Image
from pprint import pprint
import xmltodict
with open('pizza.xml') as fd:
doc = xmltodict.parse(fd.read())
file_path = doc['annotation']['path']
main_img = Image.open(file_path)