def caffe_net_thread(thread_id,solver_file_path,version,weights_file_mode,weights_file_path,command_dic,gpu_num): caffe.set_device(gpu_num) caffe.set_mode_gpu() caffe_net = Caffe_Net(solver_file_path,version,weights_file_mode,weights_file_path) cprint(d2s('Starting thread ',thread_id),'yellow','on_blue') state = command_dic[thread_id] while True: command = command_dic[thread_id] if command == 'pause': if state == 'pause': pass else: state = 'pause' cprint(d2s('Pausing thread ',thread_id),'yellow','on_blue') time.sleep(1) continue if command == 'start' and state == 'pause': state = 'running' cprint(d2s('Unpausing thread ',thread_id),'yellow','on_blue') if command == 'stop': cprint(d2s('Stopping thread ',thread_id),'yellow','on_blue') return try: data = data_list[-(1+gpu_num)] except Exception as e: cprint("********** Exception ***********************",'red') print(e.message, e.args) if data != None: caffe_net.train_step(data)
def caffe_net_thread(thread_id,solver_file_path,version,weights_file_mode,weights_file_path,command_dic,gpu_num): caffe.set_device(gpu_num) caffe.set_mode_gpu() caffe_net = Caffe_Net(solver_file_path,version,weights_file_mode,weights_file_path) cprint(d2s('Starting thread ',thread_id),'yellow','on_blue') state = command_dic[thread_id] while True: command = command_dic[thread_id] if command == 'pause thread': if state == 'pause': pass else: state = 'pause' cprint(d2s('Pausing thread ',thread_id),'yellow','on_blue') time.sleep(1) continue if command == 'start thread' and state == 'pause': state = 'running' cprint(d2s('Unpausing thread ',thread_id),'yellow','on_blue') if command == 'stop thread': cprint(d2s('Stopping thread ',thread_id),'yellow','on_blue') return if True: #try: data = access_bag_files.get_data(BF_dic,played_bagfile_dic,used_timestamps) else: #except Exception as e: cprint("********** Exception ***********************",'red') print(e.message, e.args) if data != None: caffe_net.train_step(data)
version = 'version 1' weights_file_mode = None #most recent' weights_file_path = None #opjD('z2_color') caffe_net = Caffe_Net(solver_file_path,version,weights_file_mode,weights_file_path,False) while True: try: data = data_list[-1] except Exception as e: cprint("********** Exception ***********************",'red') print(e.message, e.args) if data != None: #print data['path'] #time.sleep(1) caffe_net.train_step(data) def plot_loss1000(): l=load_obj('/home/karlzipser/Desktop/loss1000.pkl' ) plot(l,'.') x,d = sequential_means(l,500) plot(x,d,'ro-') from kzpy3.caf5.Caffe_Net import * def caffe_net_thread(thread_id,solver_file_path,version,weights_file_mode,weights_file_path,command_dic,gpu_num): caffe.set_device(gpu_num) caffe.set_mode_gpu() caffe_net = Caffe_Net(solver_file_path,version,weights_file_mode,weights_file_path)
if data != None: caffe_net.train_step(data) """ threading.Thread(target=caffe_net_thread,args=(thread_id,solver_file_path,version,weights_file_mode,weights_file_path,command_dic,gpu_num)).start() """ caffe_net = Caffe_Net(solver_file_path,version,weights_file_mode,weights_file_path) while True: try: data = access_bag_files.get_data(BF_dic,played_bagfile_dic,used_timestamps) except Exception as e: cprint("********** Exception ***********************",'red') print(e.message, e.args) if data != None: caffe_net.train_step(data) """ caffe_net = Caffe_Net.Caffe_Net(solver_file_path,version,weights_file_mode,weights_file_path) def caffe_net_thread(): caffe.set_device(0) caffe.set_mode_gpu() while True: try: data = access_bag_files.get_data(BF_dic,played_bagfile_dic,used_timestamps) except Exception as e: cprint("********** Exception ***********************",'red') print(e.message, e.args) if data != None: caffe_net.train_step(data)