Loading autocnet/control/control.py +0 −1 Original line number Diff line number Diff line Loading @@ -178,7 +178,6 @@ class ControlNetwork(object): # The node_id is a composite key (image_id, correspondence_id), so just grab the image image_id = key[0] match_id = key[1] print(self.data.columns) self.data.loc[self._measure_id] = [point_id, image_id, match_id, edge, match_idx, *fields, 0, 0, np.inf, True] self._measure_id += 1 Loading autocnet/graph/edge.py +0 −3 Original line number Diff line number Diff line Loading @@ -186,14 +186,11 @@ class Edge(dict, MutableMapping): raise TypeError keypts = node.get_keypoint_coordinates(index=index, homogeneous=homogeneous) # If we only want keypoints in the overlap print('O', overlap) if overlap: if self.source == node: mbr = self['source_mbr'] print('s', mbr) else: mbr = self['destin_mbr'] print('d', mbr) # Can't use overlap if we haven't computed MBRs if mbr is None: return keypts Loading autocnet/graph/network.py +0 −3 Original line number Diff line number Diff line Loading @@ -735,7 +735,6 @@ class CandidateGraph(nx.Graph): """ filelist = [] for i, node in self.nodes.data('data'): print(type(node), node['image_path']) filelist.append(node['image_path']) return filelist Loading Loading @@ -1151,8 +1150,6 @@ class CandidateGraph(nx.Graph): Checks if the graph is a complete graph """ neighbors = nx.degree(self) print(neighbors) print(self.nodes) for edge in neighbors: if edge == len(self.neighbors(self.nodes)): continue Loading autocnet/io/network.py +22 −14 Original line number Diff line number Diff line Loading @@ -48,8 +48,8 @@ def save(network, projectname): js_str = json.dumps(js, cls=NumpyEncoder, sort_keys=True, indent=4) pzip.writestr('graph.json', js_str) # Write the array node_attributes to hdf for n, data in network.nodes_iter(data=True): # Write the array node_attributes for n, data in network.nodes.data('data'): ndarrays_to_write = {} for k, v in data.__dict__.items(): if isinstance(v, np.ndarray): Loading @@ -64,7 +64,7 @@ def save(network, projectname): os.remove('{}.npz'.format(data['node_id'])) # Write the array edge attributes to hdf for s, d, data in network.edges_iter(data=True): for s, d, data in network.edges.data('data'): if s > d: s, d = d, s ndarrays_to_write = {} Loading Loading @@ -95,7 +95,6 @@ def load(projectname): # Read the graph object with pzip.open('graph.json', 'r') as g: data = json.loads(g.read().decode(),object_hook=json_numpy_obj_hook) cg = autocnet.graph.network.CandidateGraph() Edge = autocnet.graph.edge.Edge Node = autocnet.graph.node.Node Loading @@ -103,6 +102,9 @@ def load(projectname): cg.graph = data['graph'] # Handle nodes for d in data['nodes']: # Backwards compatible with nx 1.x proj files (64_apollo in examples) if 'data' in d.keys(): d = d['data'] n = Node() for k, v in d.items(): if k == 'id': Loading @@ -117,26 +119,32 @@ def load(projectname): pass # The node does not have features to load. cg.add_node(d['node_id'], data=n) for e in data['links']: cg.add_edge(e['source'], e['target']) edge = Edge() edge.source = cg.node[e['source']] edge.destination = cg.node[e['target']] for k, v in e.items(): s = e['source'] d = e['target'] if s > d: s,d = d,s source = cg.node[s]['data'] destination = cg.node[d]['data'] edge = Edge(source, destination) # Backwards compatible with nx 1.x proj files (64_apollo in examples) if 'data' in e.keys(): di = e['data'] else: di = e # Read the data and populate edge attrs for k, v in di.items(): if k == 'target' or k == 'source': continue edge[k] = v try: nzf = np.load(BytesIO(pzip.read('{}_{}.npz'.format(e['source'], e['target'])))) nzf = np.load(BytesIO(pzip.read('{}_{}.npz'.format(s,d)))) edge.masks = pd.DataFrame(nzf['masks'], index=nzf['masks_idx'], columns=nzf['masks_columns']) edge.matches = pd.DataFrame(nzf['matches'], index=nzf['matches_idx'], columns=nzf['matches_columns']) except: pass # Add a mock edge cg.add_edge(e['source'], e['target'] ,data=edge) cg.add_edge(s, d, data=edge) cg._order_adjacency return cg tests/conftest.py +1 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ def candidategraph(): [True, False]], columns=['rain', 'maker']) for s, d, e in cg.edges_iter(data=True): for s, d, e in cg.edges.data('data'): e['fundamental_matrix'] = np.random.random(size=(3,3)) e.matches = matches e.masks = masks Loading Loading
autocnet/control/control.py +0 −1 Original line number Diff line number Diff line Loading @@ -178,7 +178,6 @@ class ControlNetwork(object): # The node_id is a composite key (image_id, correspondence_id), so just grab the image image_id = key[0] match_id = key[1] print(self.data.columns) self.data.loc[self._measure_id] = [point_id, image_id, match_id, edge, match_idx, *fields, 0, 0, np.inf, True] self._measure_id += 1 Loading
autocnet/graph/edge.py +0 −3 Original line number Diff line number Diff line Loading @@ -186,14 +186,11 @@ class Edge(dict, MutableMapping): raise TypeError keypts = node.get_keypoint_coordinates(index=index, homogeneous=homogeneous) # If we only want keypoints in the overlap print('O', overlap) if overlap: if self.source == node: mbr = self['source_mbr'] print('s', mbr) else: mbr = self['destin_mbr'] print('d', mbr) # Can't use overlap if we haven't computed MBRs if mbr is None: return keypts Loading
autocnet/graph/network.py +0 −3 Original line number Diff line number Diff line Loading @@ -735,7 +735,6 @@ class CandidateGraph(nx.Graph): """ filelist = [] for i, node in self.nodes.data('data'): print(type(node), node['image_path']) filelist.append(node['image_path']) return filelist Loading Loading @@ -1151,8 +1150,6 @@ class CandidateGraph(nx.Graph): Checks if the graph is a complete graph """ neighbors = nx.degree(self) print(neighbors) print(self.nodes) for edge in neighbors: if edge == len(self.neighbors(self.nodes)): continue Loading
autocnet/io/network.py +22 −14 Original line number Diff line number Diff line Loading @@ -48,8 +48,8 @@ def save(network, projectname): js_str = json.dumps(js, cls=NumpyEncoder, sort_keys=True, indent=4) pzip.writestr('graph.json', js_str) # Write the array node_attributes to hdf for n, data in network.nodes_iter(data=True): # Write the array node_attributes for n, data in network.nodes.data('data'): ndarrays_to_write = {} for k, v in data.__dict__.items(): if isinstance(v, np.ndarray): Loading @@ -64,7 +64,7 @@ def save(network, projectname): os.remove('{}.npz'.format(data['node_id'])) # Write the array edge attributes to hdf for s, d, data in network.edges_iter(data=True): for s, d, data in network.edges.data('data'): if s > d: s, d = d, s ndarrays_to_write = {} Loading Loading @@ -95,7 +95,6 @@ def load(projectname): # Read the graph object with pzip.open('graph.json', 'r') as g: data = json.loads(g.read().decode(),object_hook=json_numpy_obj_hook) cg = autocnet.graph.network.CandidateGraph() Edge = autocnet.graph.edge.Edge Node = autocnet.graph.node.Node Loading @@ -103,6 +102,9 @@ def load(projectname): cg.graph = data['graph'] # Handle nodes for d in data['nodes']: # Backwards compatible with nx 1.x proj files (64_apollo in examples) if 'data' in d.keys(): d = d['data'] n = Node() for k, v in d.items(): if k == 'id': Loading @@ -117,26 +119,32 @@ def load(projectname): pass # The node does not have features to load. cg.add_node(d['node_id'], data=n) for e in data['links']: cg.add_edge(e['source'], e['target']) edge = Edge() edge.source = cg.node[e['source']] edge.destination = cg.node[e['target']] for k, v in e.items(): s = e['source'] d = e['target'] if s > d: s,d = d,s source = cg.node[s]['data'] destination = cg.node[d]['data'] edge = Edge(source, destination) # Backwards compatible with nx 1.x proj files (64_apollo in examples) if 'data' in e.keys(): di = e['data'] else: di = e # Read the data and populate edge attrs for k, v in di.items(): if k == 'target' or k == 'source': continue edge[k] = v try: nzf = np.load(BytesIO(pzip.read('{}_{}.npz'.format(e['source'], e['target'])))) nzf = np.load(BytesIO(pzip.read('{}_{}.npz'.format(s,d)))) edge.masks = pd.DataFrame(nzf['masks'], index=nzf['masks_idx'], columns=nzf['masks_columns']) edge.matches = pd.DataFrame(nzf['matches'], index=nzf['matches_idx'], columns=nzf['matches_columns']) except: pass # Add a mock edge cg.add_edge(e['source'], e['target'] ,data=edge) cg.add_edge(s, d, data=edge) cg._order_adjacency return cg
tests/conftest.py +1 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ def candidategraph(): [True, False]], columns=['rain', 'maker']) for s, d, e in cg.edges_iter(data=True): for s, d, e in cg.edges.data('data'): e['fundamental_matrix'] = np.random.random(size=(3,3)) e.matches = matches e.masks = masks Loading