def dragAnimationUpdate(): #阻尼拖拽动画 global current_map drag_kinetic_energy_x = gol.get_value("drag_kinetic_energy_x") drag_kinetic_energy_z = gol.get_value("drag_kinetic_energy_z") drag_velocity_x = math.sqrt(2 * math.fabs(drag_kinetic_energy_x)) #单位质量 drag_velocity_z = math.sqrt(2 * math.fabs(drag_kinetic_energy_z)) drag_force_x = gol.get_value("drag_f") * drag_velocity_x #阻尼定义 drag_force_z = gol.get_value("drag_f") * drag_velocity_z if drag_kinetic_energy_x < 0: drag_velocity_x = -drag_velocity_x if drag_kinetic_energy_z < 0: drag_velocity_z = -drag_velocity_z if (math.fabs(drag_velocity_x) + math.fabs(drag_velocity_z) < 1): drag_velocity_x = 0 drag_velocity_z = 0 drag_kinetic_energy_x = 0 drag_kinetic_energy_z = 0 else: current_map.OFFSET_X = current_map.OFFSET_X - (drag_velocity_x * 0.01) current_map.OFFSET_Z = current_map.OFFSET_Z - (drag_velocity_z * 0.01) drag_kinetic_energy_x = drag_kinetic_energy_x - drag_force_x * ( drag_velocity_x) * 0.01 drag_kinetic_energy_z = drag_kinetic_energy_z - drag_force_z * ( drag_velocity_z) * 0.01 gol.set_value("drag_kinetic_energy_x", drag_kinetic_energy_x) gol.set_value("drag_kinetic_energy_z", drag_kinetic_energy_z)
def lightAnimationUpdate(): #遮罩层动画 ali = gol.get_value("map_mark") if (ali > 0): ali = ali - int(math.log(ali + 1)) else: ali = 0 gol.set_value("map_mark", ali)
def get_network_status(): out = subprocess.getstatusoutput("ping 192.168.50.67 -f -c 100") #print(out) if not out[0]: re = out[1].split(',')[2:] gol.set_value("packet loss", re[0].split()[0]) gol.set_value(re[1].split(' = ')[0].split('\n')[1], re[1].split(' = ')[1])
def get_network_status(): #print(gol._global_dict) out = subprocess.getstatusoutput("ping %s -f -c 10" % gol.get_value("mcu_ip")) #print(out) if not out[0]: re = out[1].split(',')[2:] gol.set_value("packet loss", re[0].split()[0]) gol.set_value(re[1].split(' = ')[0].split('\n')[1], re[1].split(' = ')[1])
def tableInit(self): self.InitFlag = True self.Table_widget.setRowCount(0) dir = self.LineEdit_workDir.text() gol.set_value('WORKPATH', dir) for f in fc.filterFileList(fc.getModelFile(dir), EXT_LIST): QApplication.processEvents() ext = os.path.splitext(f)[1].lower() self.addRowContent([f, ext]) self.InitFlag = False
def upload(): """接受前端传送来的文件""" f = request.files['file'] if f is None: # 表示没有发送文件 msg = "未上传文件" return msg img_name = request.form.get('name') str = img_name[-11:] # 图片名称 global upload_img_path upload_img_path = os.path.join('img/', str) # 图片保存的路径 f.save(upload_img_path) gol.set_value('upload_img_path', upload_img_path) return "json.dumps(result_text)"
def JoinGroup(self): global group_name url = gol.get_value('url') hed = gol.get_value('hed') api = '/api/group/join' group_id = self.lineEdit.text() page = 1 per_page = 10 data = {'group_id': group_id} r = requests.post(url + api, json=data, headers=hed) print("加入群组") print(r.json()) group_name = r.json()['group_name'] print(group_name) gol.set_value('GroupId', group_id) gol.set_value('GroupName', group_name) self.jump_to_MainChat()
def bkAnimationUpdate(): #背景切换动画 bk_alpha = gol.get_value("bk_alpha") bk_tend = gol.get_value("bk_end") bk = gol.get_value("bk") if bk_alpha < 100: if bk_tend == 1: bk_main.set_alpha(bk_alpha) bk.blit(bk_main, (0, 0)) if bk_tend == 2: bk_hell.set_alpha(bk_alpha) bk.blit(bk_hell, (0, 0)) if bk_tend == 3: bk_end.set_alpha(bk_alpha) bk.blit(bk_end, (0, 0)) bk_alpha = bk_alpha + 1 if bk_alpha > 70 and bk_alpha < 99: bk_alpha = 99 gol.set_value("bk_alpha", bk_alpha) gol.set_value("bk", bk)
def jump_to_MainChat(self): global groups self.listWidget.setSelectionMode(QAbstractItemView.ExtendedSelection) www = self.listWidget.selectedItems() print(www) text = [i.text() for i in list(www)] splitlist = text[0].split('_') selectname = splitlist[0] GroupId = splitlist[1] gol.set_value('GroupId', GroupId) print(selectname) gol.set_value('GroupName', selectname) i = 0 self.Dialog.close() form1 = QtWidgets.QDialog() ui = MainChat.Ui_Dialog() ui.setupUi(form1) form1.show() form1.exec_() self.Dialog.close()
def Register_User(self): url = 'http://www.lunareclipse.net.cn:8000' api = '/api/user' email = self.lineEdit.text() password = self.lineEdit_2.text() nickname = self.lineEdit_4.text() data = { 'email': email, "password": password, "nickname": nickname, 'avatar': 'https://i.loli.net/2019/05/20/5ce24d067e55d75476.png' } r = requests.post(url + api, json=data) print(r.json()) if 'error' in r.json(): registerEM = r.json() message = registerEM['message'] gol.set_value('registerEM', message) print(message) self.jump_to_RegisterError()
def zoomAnimationUpdate(): #阻尼缩放动画 global current_map zoom_kinetic_energy = gol.get_value("zoom_kinetic_energy") zoom_velocity = math.sqrt(2 * math.fabs(zoom_kinetic_energy)) #单位质量 zoom_force = gol.get_value("zoom_f") * zoom_velocity if zoom_kinetic_energy < 0: zoom_velocity = -zoom_velocity if (math.fabs(zoom_velocity) < 0.2): zoom_velocity = 0 zoom_kinetic_energy = 0 else: current_map.SCALE = current_map.SCALE + (zoom_velocity * 0.01) * ( current_map.SCALE + 1) zoom_kinetic_energy = zoom_kinetic_energy - zoom_force * ( zoom_velocity) * 0.01 if current_map.SCALE > 40: current_map.SCALE = 40 if current_map.SCALE < 0.1: current_map.SCALE = 0.1 gol.set_value("zoom_kinetic_energy", zoom_kinetic_energy)
def jump_to_Login(self): id = self.lineEdit.text() password = self.lineEdit_2.text() repassword = self.lineEdit_3.text() nickname = self.lineEdit_4.text() if operator.eq(password, repassword): print('ok') self.Register_User() print(id, password, repassword, nickname) self.Dialog.close() form1 = QtWidgets.QDialog() ui = Login.Ui_Dialog() ui.setupUi(form1) form1.show() form1.exec_() self.Dialog.show() else: print('error') #registerEM = {'message': '两次输入密码不同,请重试!'} gol.set_value('registerEM', '两次输入密码不同,请重试!') self.jump_to_RegisterError()
def detailAnimationUpdate(): #细节窗口动画 detail_end = gol.get_value("detail_end") detail_endx = gol.get_value("detail_endx") detail_endy = gol.get_value("detail_endy") detail_scale = gol.get_value("detail_scale") detail_posx = gol.get_value("detail_posx") detail_posy = gol.get_value("detail_posy") err = detail_end - detail_scale errx = detail_endx - detail_posx erry = detail_endy - detail_posy detail_velocity = err * 0.14 #比例控制器 detail_velocityx = errx * 0.14 #比例控制器 detail_velocityy = erry * 0.2 #比例控制器 if (math.fabs(err) + math.fabs(errx) + math.fabs(erry)) < 0.05: detail_scale = detail_end #detail_posx = detail_endx #detail_posy = detail_endy else: detail_scale = detail_scale + detail_velocity detail_posx = detail_posx + detail_velocityx detail_posy = detail_posy + detail_velocityy gol.set_value("detail_scale", detail_scale) gol.set_value("detail_posx", detail_posx) gol.set_value("detail_posy", detail_posy)
def main(): for dq in data_queue(calc, bandwidth, last): tmp_list = list(dq) #print(tmp_list) avg10 = list(map(lambda x: round(x / 10, 2), reduce(add, tmp_list))) avg2 = list(map(lambda x: round(x / 2, 2), reduce(add, tmp_list[-2:]))) avg5 = list(map(lambda x: round(x / 5, 2), reduce(add, tmp_list[-5:]))) get_network_status() gol.set_value('avg10', avg10) gol.set_value('avg2', avg2) gol.set_value('avg5', avg5) print(gol._global_dict)
def buttonsHandler(id): #按钮响应 global route_pos_start, route_pos_end, route_switch if (id > 20 and id < 100): #按钮id if id == 23: #goto按钮 ldmk = current_map.landmarks_manager.getLandmarkById(detail_id) gol.set_value("end_offsetx", ldmk.posx) gol.set_value("end_offsetz", ldmk.posz) gol.set_value("map_jump_sw", 1) closeDetail(7) closeDetail(8) closeDetail(9) findRoute(ldmk) route_switch = 1
def Token_User(self): global hed global token global auth_token global url global groups url = 'http://www.lunareclipse.net.cn:8000' gol.set_value('url', url) # token api = '/api/token' email = self.lineEdit.text() password = self.lineEdit_2.text() r = requests.post(url + api, auth=(email, password)) auth_token = r.json()['token'] hed = {'Authorization': 'Bearer ' + auth_token} gol.set_value('hed', hed) # 获取用户信息 api = '/api/user/6' print(auth_token) print(hed) r = requests.get(url + api, headers=hed) token = r.json() print("获取用户信息") print(token) # 获取用户群组信息 api = '/api/groups' r = requests.get(url + api, headers=hed) groups = r.json() gol.set_value('groups', groups) print("获取用户群组信息") print(r.text) print(groups)
def mapOffsetAnimationUpdate(): #地图跳转动画 global max_errdis, es map_jump_sw = gol.get_value("map_jump_sw") if map_jump_sw == 1: end_offsetx = gol.get_value("end_offsetx") end_offsetz = gol.get_value("end_offsetz") errx = end_offsetx - current_map.OFFSET_X errz = end_offsetz - current_map.OFFSET_Z errdis = norm2(errx, errz) cx = errx * (-1000) #比例控制器 cz = errz * (-1000) #缩放动画有点难,咕了咕了 #if errdis > max_errdis: # max_errdis = errdis # s = current_map.SCALE #位移S型曲线插值 # if s < 10: # es = 10 # else: # es = 5 #x = max_errdis - errdis #errs = es - current_map.SCALE #if math.fabs(errs) < 0.3: # if es == 10: # es = 5 #zke = gol.get_value("zoom_kinetic_energy") #if es == 10: # zke = zke + errs * 0.1 #else: # zke = zke + (-20-errs) * 0.05 #print(errs,zke) #gol.set_value("zoom_kinetic_energy",zke) gol.set_value("drag_kinetic_energy_x", cx) gol.set_value("drag_kinetic_energy_z", cz) if math.fabs(errx) + math.fabs(errz) < 0.5: gol.set_value("map_jump_sw", 0)
def main(): gol._init() arch_version = raw_input('please input the arch version:\n') project_name = raw_input('please input the project name:\n') os.chdir('architectures/%s' % arch_version) gol.set_value('var_dict', load_var(project_name)) gol.set_value('address_mask_dict', load_address_mask(project_name)) #var_dict = load_var(project_name) #address_mask_dict = load_address_mask(project_name) device_roles, device_list, last_link_table, device_name_dict = build_hardware( project_name) gol.set_value('device_roles', device_roles) gol.set_value('device_list', device_list) gol.set_value('link_table', last_link_table) gol.set_value('device_name_dict', device_name_dict) result = build_config(project_name, device_list)
import time import gol class PRINTF(object): def add(self): gol.add_value(1) print('IS', gol.get_value(1)) def dec(self): gol.dec_value(1) print('IS', gol.get_value(1)) if __name__ == '__main__': gol._init() gol.set_value(1, 1) print('is', gol.get_value(1))
def closeDetail(id): #收缩细节窗口 for item in expanders: if item.id == id: if not item.isPassedBy(mouse_posx - SCREEN_HEIGHT, mouse_posy): item.onClick() if id == 7: gol.set_value("detail_end", 0) gol.set_value("detail_endx", 980) gol.set_value("detail_endy", 30) if id == 8: gol.set_value("detail_end", 0) gol.set_value("detail_endx", 980) gol.set_value("detail_endy", 70) if id == 9: gol.set_value("detail_end", 0) gol.set_value("detail_endx", 980) gol.set_value("detail_endy", 110) gol.set_value("detail_menu", 0) detail_controls = gol.get_value("detail_controls") detail_controls.clear() gol.set_value("detail_controls", detail_controls) detail_id = 0
def mouseClickHandler(x, y, button, mouse_area): #鼠标单击事件处理 global mouse_posx, mouse_posy, mosue_posx_old, mouse_posy_old, velocity_x, velocity_z, left_button_down, current_map, id, detail_id, bk, app_mark, map_choice_id if button == 5: #上滚轮 if mouse_area == IN_MAP: zoom_kinetic_energy = gol.get_value( "zoom_kinetic_energy") + 1 #假设物体“缩放”的质量为1 ,每次滚动给予1焦耳动能 gol.set_value("zoom_kinetic_energy", zoom_kinetic_energy) if event.button == 4: #下滚轮 if mouse_area == IN_MAP: zoom_kinetic_energy = gol.get_value("zoom_kinetic_energy") - 1 gol.set_value("zoom_kinetic_energy", zoom_kinetic_energy) if event.button == 1: #左键 if mouse_area == IN_MAP: # 地图界面单击信息处理 left_button_down = 1 velocity_x = 0 velocity_z = 0 gol.set_value("drag_kinetic_energy_x", 0) #按下键拖拽时立即消除滑动动能 gol.set_value("drag_kinetic_energy_z", 0) if mouse_area == IN_SWITCH: # 主界面单击信息处理 old_id = id for item in controls: if item.isPassedBy(x - SCREEN_HEIGHT, y) == True: id = item.onClick() for item in layers: if item.isPassedBy(x - SCREEN_HEIGHT, y) == True: (temid, se) = item.onClick() if temid == 4: gol.set_value("layer_ldmk_sw", se) if temid == 5: gol.set_value("layer_ldmc_sw", se) if temid == 6: gol.set_value("layer_wlwl_sw", se) for item in expanders: if item.isPassedBy(x - SCREEN_HEIGHT, y) == True: (temid, se) = item.onClick() expandHandler(temid, se) if se == False: for item in expanders: item.blocked = False if se == True: for item in expanders: if item.id != temid: item.blocked = True if old_id != id: for item in controls: if item.id != id: item.selected = False item.frame_color = (255, 255, 255, 2) if id == 1: current_map = gol.map_main gol.set_value("current_map", current_map) gol.set_value("bk_alpha", 0) gol.set_value("bk_end", 1) map_choice_id = 1 if id == 2: current_map = gol.map_hell gol.set_value("current_map", current_map) gol.set_value("bk_alpha", 0) gol.set_value("bk_end", 2) map_choice_id = 2 if id == 3: current_map = gol.map_end gol.set_value("current_map", current_map) gol.set_value("bk_alpha", 0) gol.set_value("bk_end", 3) map_choice_id = 3 if mouse_area == IN_DETAIL: # 弹出界面单击信息处理 detail_controls = gol.get_value("detail_controls") old_detail_id = detail_id for item in detail_controls: if item.isPassedBy(x - 50, y - 50) == True: (clickid, se) = item.onClick() if (not (clickid > 20 and clickid < 100)): detail_id = clickid buttonsHandler(clickid) if (old_detail_id != detail_id): for item in detail_controls: if item.id != detail_id: item.selected = False item.frame_color = (128, 128, 128, 255)
def expandHandler(id, selected): #展开事件处理 global id_detail if selected == True: if id == 7: gol.set_value("detail_end", 1) gol.set_value("detail_endx", 50) gol.set_value("detail_endy", 50) id_detail = 7 gol.set_value("detail_menu", 1) detail_controls = gol.get_value("detail_controls") oringinal_x = 20 oringinal_y = 15 for item in current_map.landmarks_manager.landmarks: string = str("%s (x: %d , z: %d)" % (item.name, item.posx, item.posz)) ldmk_button = control.DetailSwitch( (400, 30), (oringinal_x, oringinal_y), item.color, string, item.id) detail_controls.append(ldmk_button) oringinal_y = oringinal_y + 30 if oringinal_y > SCREEN_HEIGHT - 125: oringinal_x = oringinal_x + 410 oringinal_y = 15 control_btn_next = control.Button((32, 32), (890, 30), (0, 0, 0, 0), "操作按钮之下一页", 21, "btn_next.png") control_btn_last = control.Button((32, 32), (890, 70), (0, 0, 0, 0), "操作按钮之上一页", 22, "btn_last.png") control_btn_goto = control.Button((32, 32), (890, 140), (0, 0, 0, 0), "操作按钮之跳转", 23, "btn_goto.png") detail_controls.append(control_btn_next) detail_controls.append(control_btn_last) detail_controls.append(control_btn_goto) gol.set_value("detail_controls", detail_controls) if id == 8: gol.set_value("detail_end", 1) gol.set_value("detail_endx", 50) gol.set_value("detail_endy", 50) id_detail = 8 gol.set_value("detail_menu", 2) if id == 9: gol.set_value("detail_end", 1) gol.set_value("detail_endx", 50) gol.set_value("detail_endy", 50) id_detail = 9 gol.set_value("detail_menu", 3) if selected == False: closeDetail(id)
route_pos_end = (1, 1) route_switch = 0 #导航开关 route_title = " " route_str1 = "尚无相关交通信息,建议直接tp" route_str2 = " " route_under_bed = 0 route_production = " " route_description = "暂无介绍" route_photo = None detail_controls = [] current_map = gol.get_value("current_map") #初始化 gol.set_value("map_mark", 255) def findRoute(ldmk): #导航规划 global route_pos_start, route_pos_end, route_str1, route_str2, route_title, route_under_bed, route_photo, route_production, route_description if map_choice_id == 1: posx_b = int(ldmk.posx / 8) #下界对应坐标 posz_b = int(ldmk.posz / 8) point_b = (posx_b, posz_b) min_distance = 1000000000 ldmk_b = None for item in gol.map_hell.landmarks_manager.landmarks: point_a = (item.posx, item.posz) dis = distance(point_a, point_b) if dis < min_distance and item.dor == True: min_distance = dis
print('方剂名: ', prescript['方剂名']) print('推荐药物:',prescript['药物组成']) print('用法用量:',prescript['用法用量']) print('主治: ',prescript['主治']) print() else: for i, prescript in enumerate(prescript_list): print('方剂名: ', prescript['方剂名']) print('推荐药物:',prescript['药物组成']) print('用法用量:',prescript['用法用量']) print('主治: ',prescript['主治']) print() print('核心药物集合:','、'.join([x[0] for x in main_med])) if __name__ == '__main__': gol._init() ENTITY_FILE = gol.set_value('ENTITY_FILE', 'data/symptom_entity.csv') # 添加实体的方剂文件 CODE = gol.set_value('CODE', 'UTF-8') # code SYNONYM_FILE = gol.set_value('SYNONYM_FILE', 'data/clean2.txt') # 同义词 num_4_group = 2 num_4_other = 2 '''构建索引''' # 存放索引的文件夹 indexfile = 'index/' # 同义词词典路径 # dictfile = 'dict/synonym.txt' dictfile = 'data/clean2.txt' # 方剂数据集路径 datasetfile = 'data/symptom_entity.csv' # 创建索引 # who.get_index(datasetfile, indexfile)
def demo(opt): os.environ['CUDA_VISIBLE_DEVICES'] = opt.gpus_str opt.debug = max(opt.debug, 1) Detector = detector_factory[opt.task] detector = Detector(opt) if opt.demo == 'webcam' or \ opt.demo[opt.demo.rfind('.') + 1:].lower() in video_ext: cam = cv2.VideoCapture(0 if opt.demo == 'webcam' else opt.demo) detector.pause = False while True: _, img = cam.read() #print(img.shape) #cv2.imshow('input', img) ret = detector.run(img) time_str = '' for stat in time_stats: time_str = time_str + '{} {:.3f}s |'.format(stat, ret[stat]) print(time_str) if cv2.waitKey(1) == 27: return elif opt.demo == '435': # Configure depth and color streams pipeline = rs.pipeline() # 创建 config 对象: config = rs.config() config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30) config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30) # Start streaming profile = pipeline.start(config) # Getting the depth sensor's depth scale (see rs-align example for explanation) depth_sensor = profile.get_device().first_depth_sensor() depth_scale = depth_sensor.get_depth_scale() print("Depth Scale is: ", depth_scale) # We will be removing the background of objects more than # clipping_distance_in_meters meters away clipping_distance_in_meters = 1 #meters clipping_distance = clipping_distance_in_meters / depth_scale align_to = rs.stream.color align = rs.align(align_to) i = 0 timeF = 30 while True: # Wait for a coherent pair of frames(一对连贯的帧): depth and color frames = pipeline.wait_for_frames() aligned_frames = align.process(frames) aligned_depth_frame = aligned_frames.get_depth_frame() gol.set_value('aligned_depth_frame', aligned_depth_frame) #定义跨模块全局变量 color_frame = aligned_frames.get_color_frame() # # Intrinsics & Extrinsics # #深度相机内参矩阵 # depth_intrin = aligned_depth_frame.profile.as_video_stream_profile().intrinsics # #RGB相机内参矩阵 # color_intrin = color_frame.profile.as_video_stream_profile().intrinsics # # 外参矩阵-深度图相对于彩色图像的外参RT # depth_to_color_extrin = aligned_depth_frame.profile.get_extrinsics_to(color_frame.profile) # print("内参 ppx,ppy",depth_intrin.ppx, ':', depth_intrin.ppy) # print("内参矩阵",depth_intrin) if not aligned_depth_frame or not color_frame: continue color_image = np.asanyarray(color_frame.get_data()) #global depth_image depth_image = np.asanyarray(aligned_depth_frame.get_data()) # Remove background - Set pixels further than clipping_distance to grey grey_color = 153 depth_image_3d = np.dstack( (depth_image, depth_image, depth_image)) #depth image is 1 channel, color is 3 channels bg_removed = np.where( (depth_image_3d > clipping_distance) | (depth_image_3d <= 0), grey_color, color_image) # Apply colormap on depth image (image must be converted to 8-bit per pixel first) depth_colormap = cv2.applyColorMap( cv2.convertScaleAbs(depth_image, alpha=0.03), cv2.COLORMAP_JET) # Stack both images horizontally images = np.hstack((bg_removed, depth_colormap)) # #imwrite depth_image color_iamge # if i%timeF==0: # cv2.imwrite('./mydata/savefig/rgb/image_r_{}.png'.format(str(i).zfill(5)), color_image) # cv2.imwrite('./mydata/savefig/depth/image_d_{}.png'.format(str(i).zfill(5)), depth_colormap) # cv2.imwrite('./mydata/savefig/depth/images_stack_{}.png'.format(str(i).zfill(5)), images) # np.savetxt("./mydata/savefig/depth_csv/depth_image_{}.csv".format(str(i).zfill(5)),depth_image,fmt="%d",delimiter=",") # i+=30 # #Show images cv2.namedWindow('Remove Background', cv2.WINDOW_AUTOSIZE) cv2.imshow('Remove Background', images) cv2.namedWindow('RealSense', cv2.WINDOW_AUTOSIZE) cv2.imshow('RealSense', color_image) # # 通过对齐后的深度图,对齐原始RGB:color_frame,保存彩色点云 # pc = rs.pointcloud() # pc.map_to(color_frame) # points = pc.calculate(aligned_depth_frame) # points.export_to_ply('./out.ply', color_frame) # #pcd = read_point_cloud(file_path) # # Visualize PLY # #draw_geometries([pcd]) ret = detector.run(color_image) time_str = '' for stat in time_stats: time_str = time_str + '{} {:.3f}s |'.format(stat, ret[stat]) print(time_str) if cv2.waitKey(1) & 0xff == ord('q'): return else: if os.path.isdir(opt.demo): image_names = [] ls = os.listdir(opt.demo) for file_name in sorted(ls): ext = file_name[file_name.rfind('.') + 1:].lower() if ext in image_ext: image_names.append(os.path.join(opt.demo, file_name)) else: image_names = [opt.demo] for (image_name) in image_names: ret = detector.run(image_name) time_str = '' for stat in time_stats: time_str = time_str + '{} {:.3f}s |'.format(stat, ret[stat]) print(time_str)
from PyQt5.Qt import * from PyQt5.QtCore import * from PyQt5.QtGui import * import json import sys import shutil import re import os from subprocess import Popen, PIPE import function as fc import threading import gol gol._init() gol.set_value('WORKPATH', None) MATSTARTCOL = 3 EXT_LIST = ['.step', '.sldprt', '.stp', '.sldasm'] # PARTEXT = ['.step', '.sldprt'] WORKDIR = os.getcwd() MATDIROOT = os.path.expanduser('~') + "\\Documents\\KeyShot 9\\Materials" class ComboBox(QComboBox): comboboxchange = pyqtSignal(int, int, str) def __init__(self, parent): super(ComboBox, self).__init__(parent=parent) class MainWindow(QMainWindow):
# coding:utf-8 from flask import Flask, request import base64 import gol import tensorflow as tf from preprocessing import preprocessing_factory import reader import model import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' gol._init() # 先必须在主模块初始化(只在Main模块需要一次即可) gol.set_value('upload_img_path', "") upload_img_path = gol.get_value('upload_img_path') def img(image_file='img/test.jpg', loss_model='vgg_16', image_size=256, model_file='models/wave.ckpt-done'): height = 0 width = 0 with open(image_file, 'rb') as img: with tf.Session().as_default() as sess: if image_file.lower().endswith('png'): image = sess.run(tf.image.decode_png(img.read())) else: image = sess.run(tf.image.decode_jpeg(img.read())) height = image.shape[0] width = image.shape[1] # tf.logging.info('Image size: %dx%d' % (width, height))
def exec(): nic_ip, mcu_ip = get_mcu_ip() iface_obj = GetIfaces() nic = iface_obj.get_nic(nic_ip) gol.set_value('mcu_ip', mcu_ip) gol.set_value('nic_ip', nic_ip) gol.set_value('nic', nic) exec_iptables_cmd(mcu_ip) time.sleep(1) for dq in data_queue(calc, bandwidth, last): tmp_list = list(dq) #print(tmp_list) avg10 = list(map(lambda x: round(x / 10, 2), reduce(add, tmp_list))) avg2 = list(map(lambda x: round(x / 2, 2), reduce(add, tmp_list[-2:]))) avg5 = list(map(lambda x: round(x / 5, 2), reduce(add, tmp_list[-5:]))) get_network_status() gol.set_value('avg10', avg10) gol.set_value('avg2', avg2) gol.set_value('avg5', avg5)