Best Python code snippet using localstack_python
RetinaNetFilteredDetectionsReplacement.py
Source:RetinaNetFilteredDetectionsReplacement.py  
...33    equal to "caffe.PriorBoxParameter.CORNER" produces the same result as the post-processing in the original topology.34    """35    replacement_id = 'RetinaNetFilteredDetectionsReplacement'36    @staticmethod37    def _create_sub(graph: nx.MultiDiGraph, input_1: Node, port_1: int, input_2: Node, port_2: int):38        negate = Power(graph, dict(scale=-1, name=input_2.name + '/negate_'))39        add = Eltwise(graph, dict(operation='sum', name=input_1.name + '/add_'))40        out_node = add.create_node([(input_1, port_1), negate.create_node([(input_2, port_2)])])41        return out_node42    def output_edges_match(self, graph: nx.DiGraph, match: SubgraphMatch, new_sub_graph: dict):43        return {match.output_node(0)[0].id: new_sub_graph['detection_output_node'].id}44    def nodes_to_remove(self, graph: nx.MultiDiGraph, match: SubgraphMatch):45        new_nodes_to_remove = match.matched_nodes_names()46        new_nodes_to_remove.remove(match.single_input_node(0)[0].id)47        new_nodes_to_remove.remove(match.single_input_node(1)[0].id)48        new_nodes_to_remove.remove(match.single_input_node(2)[0].id)49        return new_nodes_to_remove50    def generate_sub_graph(self, graph: nx.MultiDiGraph, match: SubgraphMatch):51        reshape_classes_op = Reshape(graph, {'dim': np.array([0, -1])})52        reshape_classes_node = reshape_classes_op.create_node([match.single_input_node(1)[0]],53                                                              dict(name='do_reshape_classes'))54        priors_node = match.single_input_node(2)[0]55        placeholder = [Node(graph, node_id) for node_id in graph.nodes() if Node(graph, node_id).op == 'Placeholder'][0]56        im_height = placeholder.shape[1]57        im_width = placeholder.shape[2]58        # scale prior boxes to the [0, 1] interval59        priors_scale_const_node = Const(graph, {'value': np.array([1 / im_width,60                                                                   1 / im_height,61                                                                   1 / im_width,62                                                                   1 / im_height])}).create_node([])63        priors_scale_node = Eltwise(graph, {'name': 'scale_priors', 'operation': 'mul'}).create_node(64            [priors_node, priors_scale_const_node])65        # calculate prior boxes widths and heights66        split_node = SplitV(graph, {'axis': 2, 'size_splits': [1, 1, 1, 1]}).create_node([priors_scale_node])67        priors_width_node = __class__._create_sub(graph, split_node, 2, split_node, 0)68        priors_height_node = __class__._create_sub(graph, split_node, 3, split_node, 1)69        # concat weights and heights into a single tensor and multiple with the box coordinates regression values70        concat_width_height_node = Concat(graph, {'name': 'concat_priors_width_height', 'axis': -1}).create_node(71            [priors_width_node, priors_height_node, priors_width_node, priors_height_node])72        applied_width_height_regressions_node = Eltwise(graph, {'name': 'final_regressions', 'operation': 'mul'}). \73            create_node([concat_width_height_node, match.single_input_node(0)[0]])74        # reshape to 2D tensor as Inference Engine Detection Output layer expects75        reshape_regression_op = Reshape(graph, {'dim': np.array([0, -1])})76        reshape_regression_node = reshape_regression_op.create_node([applied_width_height_regressions_node],77                                                                    {'name': 'reshape_regression'})78        detection_output_op = DetectionOutput(graph, match.custom_replacement_desc.custom_attributes)79        detection_output_op.attrs['old_infer'] = detection_output_op.attrs['infer']80        detection_output_op.attrs['infer'] = __class__.do_infer81        detection_output_node = detection_output_op.create_node(82            [reshape_regression_node, reshape_classes_node, priors_scale_node],...menu.py
Source:menu.py  
...19    def _close_sub_janel(self):20        self.sub_window.destroy()21        self.sub_window = None22        self.sub_menu = None23    def _create_sub(self, text, function):24        if self.sub_window is not None:25            self.sub_window.lift()26        else:27            self.sub_window = front_page("200x200", self._close_sub_janel, self)28            self.sub_menu = SubMenu(text, function, self.sub_window)29    def _button_create(self):30        self._create_sub((31            "Create Room",32            "Name Player: ",33            "Name Room: ",34            "Password: "35        ), self.intergame.game_to_server.create_room)36    def _button_enter(self):37        self._create_sub((38            "Enter Room",39            "Name Player: ",40            "Id Room: ",41            "Password: "42        ), self.intergame.game_to_server.enter_room)43    def destroy(self):44        if self.sub_window is not None:45            self.sub_window.destroy()46        self.label = self.button_create = self.button_enter \47            = self.sub_window = self.sub_menu = None...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
