def get_bad_joints_distance_based(mesh, fit_len=11, infl_limit=0.2): # Gets vertices under every joint in skin cluster sc = f.get_skin_cluster(mesh) jnts = cmds.skinCluster(sc, query=True, inf=True) jnts_vtxs_infl = f.get_sc_multi(mesh) jnt_vtx_data = {} zero_infl_jnts = get_zero_weight_jnts(mesh) infl_jnts = [jnt for jnt in jnts if jnt not in zero_infl_jnts] for jnt in infl_jnts: vtxs_infl = jnts_vtxs_infl[jnt] cmds.select(clear=True) cmds.skinCluster(sc, e=True, selectInfluenceVerts=jnt) jnt_vtxs = cmds.ls(sl=True, fl=True) # Filters anything else except vtxs jnt_vtxs = [i for i in jnt_vtxs if cmds.objectType(i) == 'mesh'] # Gets out vertex digit id only jnt_vtxs = [ ''.join(c for c in vtx_id.split('.')[-1] if c.isdigit()) for vtx_id in jnt_vtxs ] jnt_vtxs = [int(vtx_id) for vtx_id in jnt_vtxs] # Removes low infl vertex from the list jnt_vtxs = [ vtx_id for vtx_id in jnt_vtxs if vtxs_infl[str(vtx_id)] > infl_limit ] if jnt_vtxs: jnt_vtx_data[jnt] = jnt_vtxs else: zero_infl_jnts.append(jnt) # pprint.pprint(jnt_vtx_data) jnt_vtxs_length = {} for jnt, vtxs in jnt_vtx_data.iteritems(): vtxs_pos = [f.get_pos('%s.vtx[%s]' % (mesh, vtx)) for vtx in vtxs] jnt_pos = f.get_pos(jnt) jnt_vtx_len = [f.get_length(jnt_pos, vtx_pos) for vtx_pos in vtxs_pos] # print jnt, jnt_vtx_len av_len = average(jnt_vtx_len) jnt_vtxs_length[jnt] = av_len # pprint.pprint(jnt_vtxs_length) ''' for jnt, av in jnt_vtxs_length.iteritems(): if av >= fit_len: print jnt, av ''' cmds.select(clear=True) return [jnt for jnt, av in jnt_vtxs_length.iteritems() if av >= fit_len ] + zero_infl_jnts '''
def forward(self, x): ker_size = self.ker_size stride = self.stride pad = self.pad ## allocate spaces for the output N, m, n, D = x.shape rows = (m + pad * 2 - ker_size) // stride + 1 cols = (n + pad * 2 - ker_size) // stride + 1 # pad the image if pad != 0: x = F.pad2d(x, pad) ## store input shape for backpropgation self.input_shape = x.shape # get position map maps = F.get_pos(x.shape, (ker_size, ker_size), stride) # store maps to do backpropgation self.maps = maps # get im2col self.X = F.im2col(x, maps) out = np.matmul(self.X, self.W) + self.B.reshape(1, -1) return out.reshape(N, rows, cols, -1)
def forward(self, x): s = self.kersize N, m, n, D = x.shape assert (m % s == 0) assert (n % s == 0) ## calculate the output rows orows = m // s ocols = n // s maps = F.get_pos(x.shape, (s, s), s) im2col = F.im2col(x, maps) rows, _ = im2col.shape im2col = im2col.reshape(rows, -1, D) im_max = np.max(im2col, 1) ## store which elements are biggest self.weights = np.argmax(im2col, 1) return im_max.reshape(N, orows, ocols, D)
def main(): SPI_GETWORKAREA = 48 SM_CYSCREEN = 1 def get_taskbar_size(): SystemParametersInfo = windll.user32.SystemParametersInfoA work_area = wintypes.RECT() if SystemParametersInfo(SPI_GETWORKAREA, 0, byref(work_area), 0): GetSystemMetrics = windll.user32.GetSystemMetrics return GetSystemMetrics(SM_CYSCREEN) - work_area.bottom def update_pos(*args): position.config(values=positions[tkvar.get().lower()]) pos.set(positions[tkvar.get().lower()][0]) champs = [] scale = 0.8 try: with open( "/Riot Games/League of Legends/Config/LCULocalPreferences.yaml" ) as file: for line in file: if "ZoomScale" in line: scale = float(line[-9:]) except FileNotFoundError: pass try: with open("champs.json") as file: champs = json.load(file) except FileNotFoundError: get_champions("champs.json") with open("champs.json") as file: champs = json.load(file) try: with open("runes.json") as file: rn = json.load(file) except FileNotFoundError: get_runes("runes.json") with open("runes.json") as file: rn = json.load(file) positions = get_pos(champs) screen_size = pygui.size() client = ( screen_size[0] / 2 - (1024 * scale / 0.8) / 2, (screen_size[1] - get_taskbar_size()) / 2 - (576 * scale / 0.8) / 2, ) root = Tk() root.title("Runes") root.geometry("350x120") tkvar, lang, pos, tree = ( StringVar(root), StringVar(root), StringVar(root), StringVar(root), ) tkvar.set("Aatrox") lang.set("en") pos.set("Top") tree.set("Mais Popular") menu = Combobox(root, textvariable=tkvar, values=champs) menu.bind("<<ComboboxSelected>>", update_pos) menu.place(x=20, y=70) language = Combobox( root, textvariable=lang, values=["en", "pt"], state="readonly", width=2 ) language.place(x=20, y=20) position = Combobox( root, textvariable=pos, values=positions[tkvar.get().lower()], state="readonly", width=7, ) position.place(x=90, y=20) tree_choose = Combobox( root, textvariable=tree, values=["Most Popular", "Best Winrate"], state="readonly", width=15, ) tree_choose.place(x=180, y=20) button = Button( root, text="Start", command=lambda: make_page( get_tree(tkvar.get(), pos.get(), tree.get(), rn), lang.get(), scale, client ), ) button.place(x=225, y=68) root.mainloop()
def update(bake=False): def namespaced(n): return '%s:%s' % (name_space, n) cmds.currentUnit(time='pal') if not f.exists(scene_check_joints): exit_message = 'Not all joints from %s present in scene' % scene_check_joints sys.exit(exit_message) # Imports file in scene with a given name space import_file = cmds.fileDialog2(dialogStyle=2, fm=1)[0] name_space = os.path.basename(import_file).split('.')[0] + '_namespace' cmds.file(import_file, i=True, namespace=name_space) # Delete animation from joints in Biped hierarchy cmds.currentTime(0) cmds.select(f.get_joints()) cmds.cutKey() # Exports skin cluster weights for body meshes in scene all_meshes = f.get_meshes() head_meshes = [] search_pattern_r = '|'.join([sp for sp in search_pattern.split('\n')]) regex = r"\b.*(%s).*\b" % search_pattern_r for m in all_meshes: if re.search(regex, m): head_meshes.append(m) body_meshes = [m for m in all_meshes if m not in head_meshes] if body_meshes: cmds.select(body_meshes) sie.export_weights_sp() for sc in cmds.ls(type='skinCluster'): cmds.skinCluster(sc, ub=True, edit=True) # Deletes bind poses in scene cmds.delete(cmds.ls(type='dagPose')) # Checks if scene joints are scaled length = f.get_length(f.get_pos(length_joints[0]), f.get_pos(length_joints[1])) imported_length = f.get_length(f.get_pos(namespaced(length_joints[0])), f.get_pos(namespaced(length_joints[1]))) scale_factor = length / imported_length if round(scale_factor, 0) != 1: scaled_joints_group = cmds.group(namespaced(root_joint)) cmds.xform(scaled_joints_group, scale=(scale_factor, scale_factor, scale_factor)) # Aligns imported skeleton to the one in scene # All created constraints will be deleted alongside with imported mesh later cmds.pointConstraint(head_joint, namespaced(head_joint)) head_children_joints = cmds.listRelatives(head_joint, ad=True, type='joint') head_children_joints = filter_nubs(head_children_joints) for j in head_children_joints: if f.exists(namespaced(j)): f.unlock_attributes(j) cmds.pointConstraint(namespaced(j), j) cmds.orientConstraint(namespaced(j), j) # Keys all biped joints to prevent joints shift if bake: # Gets information about keyed range of imported bones ns_biped = [ namespaced(j) for j in f.get_joints() if f.exists(namespaced(j)) ] imported_biped_keys = cmds.keyframe(ns_biped, query=True, timeChange=True) ns_min, ns_max = min(imported_biped_keys), max(imported_biped_keys) cmds.bakeResults(f.get_joints(), time=(ns_min, ns_max + 1), sm=True) cmds.playbackOptions(min=ns_min, max=ns_max + 1) else: cmds.setKeyframe(f.get_joints(), time=0) cmds.namespace(removeNamespace=name_space, deleteNamespaceContent=True) # Imports all skin cluster weights for meshes in scene cmds.select(f.get_meshes()) sie.import_weights_sp() # Fix eyes joints pivot. # When bones are imported from another character sy = batch_skin_eyes.SkinEyes() sy.set_skin()