Skip to content

Instantly share code, notes, and snippets.

@qnkhuat
qnkhuat / .vimrc
Last active November 20, 2018 03:53
call plug#begin()
" Install multiple cursors"
Plug 'terryma/vim-multiple-cursors'
" Git status "
Plug 'airblade/vim-gitgutter'
" Quick find "
Plug 'kien/ctrlp.vim'
# Important : Type :PlugInstall for the first time use
# install pathogen
mkdir -p ~/.vim/autoload ~/.vim/bundle && curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
# install monokai color
mkdir ~/.vim/colors
curl https://raw.githubusercontent.com/tomasr/molokai/master/colors/molokai.vim -o ~/.vim/colors/molokai.vim
# install plug
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: osx-64
_tflow_select=2.3.0=mkl
absl-py=0.6.1=py36_0
asn1crypto=0.24.0=py36_0
astor=0.7.1=py36_0
atomicwrites=1.2.1=py36_0
attrs=18.2.0=py36h28b3542_0
automat=0.7.0=py36_0
name: dev
channels:
- pytorch
- defaults
dependencies:
- _tflow_select=2.3.0=mkl
- absl-py=0.6.1=py36_0
- asn1crypto=0.24.0=py36_0
- astor=0.7.1=py36_0
- atomicwrites=1.2.1=py36_0
h5py
keras
numpy
pandas
pillow
scikit-learn
scipy
scrapy
seaborn
tensorboard
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@qnkhuat
qnkhuat / microsoft_face_api.py
Last active April 22, 2019 09:10
Emotion recognition using microsoft api with local image
import requests
import matplotlib.pyplot as plt
from PIL import Image
from matplotlib import patches
from io import BytesIO
face_api_url = _url # https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect
headers = {'Content-Type': 'application/octet-stream', 'Ocp-Apim-Subscription-Key': subscription_key}
params = {
@qnkhuat
qnkhuat / predict_array.py
Last active August 11, 2020 04:41
fastai predict array
from fastai.vision import Image,pil2tensor
import cv2
def array2tensor(x):
""" Return an tensor image from cv2 array """
x = cv2.cvtColor(x,cv2.COLOR_BGR2RGB)
return Image(pil2tensor(x,np.float32).div_(255))
### USAGE
@qnkhuat
qnkhuat / timing.py
Last active October 20, 2022 03:13
Timing processes in python with context manager
from contextlib import contextmanager
import time
@contextmanager
def timing(description: str = '') -> None:
start = time.time()
yield
print(f"Elasped {description}: {time.time() - start}")
@qnkhuat
qnkhuat / pathlib_extended.py
Last active September 24, 2020 07:59
Extend methods of Path from pathlib
from pathlib import Path
from glob import glob
Path.ls = lambda x : [o.name for o in x.iterdir()]
Path.ls_p = lambda x : [str(o) for o in x.iterdir()]
Path.str = lambda x : str(x)
def insensitive_glob(root, pattern):
def either(c):
return '[%s%s]' % (c.lower(), c.upper()) if c.isalpha() else c