Skip to content

Instantly share code, notes, and snippets.

@qzane
qzane / test.py
Last active August 26, 2022 03:04
Python3 global and nonlocal
a = 0 # global
def change1():
a = 1 # nonlocal
def change2():
nonlocal a
a = 3
def change3():
global a
print('change3', a)
a = 4
@qzane
qzane / make_dataset.py
Last active August 17, 2022 08:55
dataset maker for CIHP_PGN
# dataset maker for https://github.com/Engineering-Course/CIHP_PGN
# author: qzane@live.com
import os,sys,shutil
from PIL import Image
import numpy as np
DATA_TYPE = ['png','PNG','jpg','JPG']
def main():
USAGE = "python %s /path_to_images name_of_dataset" % sys.argv[0]
#!/usr/bin/env python
#-*- coding: UTF-8 -*-
import sys, os, re, time, pkgutil, logging, click, subprocess, zipfile
from jinja2 import Template, Environment, PackageLoader
from datetime import datetime
__version__ = "1.1"
RE_CHAPTER_AND_SECTIONS=[
import os,sys,shutil
import cv2
import numpy as np
USAGE = "python %s video [outPath]"%sys.argv[0]
USAGE += "\n example: python %s video.mp4 ./output"%sys.argv[0]
if len(sys.argv) < 2 or '-h' in sys.argv or '--help' in sys.argv:
print(USAGE)
@qzane
qzane / smplx_uv.py
Created October 10, 2020 20:39
get colored uv map for SMPL/SMPLX model
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 10 15:29:24 2020
@author: qzane
The SMPLX models can be find at: https://smpl-x.is.tue.mpg.de/
"""
import numpy as np
import scipy
from scipy.ndimage.measurements import label
def solve_RT1_RT2(A, B):
''' solve for B = x1.dot(A).dot(x2)
A = [[[R1,T1],[0,1]]...] # shape: (n,4,4)
B = [[[R2,T2],[0,1]]...] # shape: (n,4,4)
minimize{np.einsum('jk,ikp,pq->ijq', x1, A, x2)-B}
return: x1,x2: shape(4,4)
'''
def func(x,a,b):
x1 = x[:16].reshape(4,4)
x2 = x[16:].reshape(4,4)
@qzane
qzane / utils.py
Created April 29, 2020 19:19
Some scripts for medical image processing
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 28 14:34:17 2018
@author: qzane
"""
import os,sys
import numpy as np
@qzane
qzane / detectron2-on-longleaf.md
Created November 10, 2019 19:46
detectron2-on-longleaf.md

how to run detectron2 on longleaf

1. install anaconda

module add anaconda
module add gcc/4.9.1
module add cuda/9.2
module save
@qzane
qzane / speaker.py
Last active January 2, 2019 05:47
tts for stardict
#update Jan-02-2019:
#to use with stardict:
# 1. sudo apt-get remove stardict-plugin-espeak stardict-plugin-festival
# 2. Preferences -> Dictionary -> Sound -> Use TTS program -> Commandline: /PYTHON_PATH/python /SCIRPY_PATH/speaker.py %s &
#todo: combine play_win_wav & play_win
#todo: combine checkRealVoice & checkVoice
#----speaker.py by me@qzane.com------#
#----2016-08-31----------------------#
import sys
#!/usr/bin/python
import os,sys
import time
import random
import numpy as np
from sklearn.svm import SVR,SVC