def map_features_thread(X, theta_u, theta_v, images, data_dir, view, num_threads): X_split = np.array_split(X, num_threads) processes = [] feature_dir = data_dir + 'features/' print feature_dir if not os.path.exists(feature_dir): os.makedirs(feature_dir) print feature_dir files = glob.glob(feature_dir+'*') for f in files: os.remove(f) for i in range(num_threads): processes.append( worker( target = map_features, name="Thread #%d" % i, args=(X_split[i], theta_u, theta_v, images, i, feature_dir) ) ) [t.start() for t in processes] [t.join() for t in processes] feature_all = [] for i in range(num_threads): feature = np.load(feature_dir + str(i) + '.npy') feature_all.append(feature) feature_all = np.vstack(feature_all).astype(np.float16) np.save(data_dir + 'f16_' + view + '.npy', feature_all)
def main(): data_root = '/scail/scratch/group/vision/bypeng/healthcare/shotton/shotton_people/' npy_root = '/scail/scratch/group/vision/hospital/ITOP/' views = ['side', 'top'] num_joints = {'side':15, 'top':15} num_pixel_per_joint = {'side':200, 'top':300} num_people = 12 range1 = range(8, 12) for view in views: processes = [] # for i in range(num_people): for i in range1: index = str(i).zfill(2) image = np.load(npy_root+index+'_depth_'+view+'.npy') label = np.load(npy_root+index+'_predicts_'+view+'.npy') dir_path = data_root + 'person_' + index + '/' print 'Load', npy_root+index+'_depth_'+view+'.npy', 'Save to', dir_path if not os.path.exists(dir_path): os.makedirs(dir_path) processes.append( worker( target = processData, name="Thread #%d" % i, args=(image, label, num_joints[view], num_pixel_per_joint[view], dir_path, view) ) ) [t.start() for t in processes] [t.join() for t in processes]
def main(): data_root = '/scail/scratch/group/vision/bypeng/healthcare/shotton/shotton_people/' npy_root = '/scail/scratch/group/vision/hospital/ITOP/' views = ['side', 'top'] num_joints = {'side': 15, 'top': 15} num_pixel_per_joint = {'side': 200, 'top': 300} num_people = 12 range1 = range(8, 12) for view in views: processes = [] # for i in range(num_people): for i in range1: index = str(i).zfill(2) image = np.load(npy_root + index + '_depth_' + view + '.npy') label = np.load(npy_root + index + '_predicts_' + view + '.npy') dir_path = data_root + 'person_' + index + '/' print 'Load', npy_root + index + '_depth_' + view + '.npy', 'Save to', dir_path if not os.path.exists(dir_path): os.makedirs(dir_path) processes.append( worker(target=processData, name="Thread #%d" % i, args=(image, label, num_joints[view], num_pixel_per_joint[view], dir_path, view))) [t.start() for t in processes] [t.join() for t in processes]
def main(): ''' Two threads are started for receive data and the send data is called by main thread. ''' print("Enter the number of people to call : ") n = int(input("")) print("Enter the ip address of the server") ip = sys.stdin.readline() ip = ip.strip() port = [7001, 9002] t = [] if n == 2: t.append(worker(target=recvData, args=(port[0], ))) t.append(worker(target=recvData, args=(port[1], ))) t[0].start() t[1].start() else: t.append(worker(target=recvData, args=(port[0], ))) t[0].start() sendData(6002, ip)
def main_1(): data_root = '/mnt0/data/ITOP/all/' npy_root = '/mnt0/data/ITOP/out/' data_files = listdir(data_root) num_people = 12 processes = [] for i in range(num_people): index = str(i).zfill(2) person_i = [data_root+f for f in data_files if \ len(re.findall(r"\b"+index+"_", f)) != 0] person_i.sort() print 'Processing person', i, 'Num frames', len(person_i) processes.append( worker(target=load_data_new, name="Thread #%d" % i, args=(person_i, index, npy_root))) [t.start() for t in processes] [t.join() for t in processes]
def main_1(): data_root = '/mnt0/data/ITOP/all/' npy_root = '/mnt0/data/ITOP/out/' data_files = listdir(data_root) num_people = 12 processes = [] for i in range(num_people): index = str(i).zfill(2) person_i = [data_root+f for f in data_files if \ len(re.findall(r"\b"+index+"_", f)) != 0] person_i.sort() print 'Processing person', i, 'Num frames', len(person_i) processes.append( worker( target=load_data_new, name="Thread #%d" % i, args=(person_i, index, npy_root) ) ) [t.start() for t in processes] [t.join() for t in processes]
yield c + i char = string.digits + string.ascii_lowercase site = '.google.com' def getaddr(): while True: url = q.get() try: res = socket.getaddrinfo(url, 80) print(url + ":" + res[0][4][0]) except: pass q.task_done() NUM = 1000 #thread's num q = Queue() for host in create_host(char): q.put(host + site) for i in range(NUM): w = worker(target=getaddr) w.start() end = time.time() print(end - start)
for c in char: yield c + i char = string.digits + string.ascii_lowercase site = '.google.com' def getaddr(): while True: url = q.get() try: res = socket.getaddrinfo(url,80) print(url + ":" + res[0][4][0]) except: pass q.task_done() NUM=1000 #thread's num q=Queue() for host in create_host(char): q.put(host+site) for i in range(NUM): w=worker(target=getaddr) w.start() end = time.time() print(end-start)