Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
020efa74
Commit
020efa74
authored
Jan 27, 2018
by
cclauss
Browse files
CogMap: Fix five undefined names
parent
0f2fc58d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
9 deletions
+11
-9
research/cognitive_mapping_and_planning/src/depth_utils.py
research/cognitive_mapping_and_planning/src/depth_utils.py
+2
-1
research/cognitive_mapping_and_planning/src/file_utils.py
research/cognitive_mapping_and_planning/src/file_utils.py
+1
-1
research/cognitive_mapping_and_planning/src/graph_utils.py
research/cognitive_mapping_and_planning/src/graph_utils.py
+8
-7
No files found.
research/cognitive_mapping_and_planning/src/depth_utils.py
View file @
020efa74
...
@@ -16,7 +16,8 @@
...
@@ -16,7 +16,8 @@
"""Utilities for processing depth images.
"""Utilities for processing depth images.
"""
"""
import
numpy
as
np
import
numpy
as
np
import
src.rotation_utils
as
ru
import
src.rotation_utils
as
ru
import
src.utils
as
utils
def
get_camera_matrix
(
width
,
height
,
fov
):
def
get_camera_matrix
(
width
,
height
,
fov
):
"""Returns a camera matrix from image size and fov."""
"""Returns a camera matrix from image size and fov."""
...
...
research/cognitive_mapping_and_planning/src/file_utils.py
View file @
020efa74
...
@@ -34,7 +34,7 @@ def write_image(image_path, rgb):
...
@@ -34,7 +34,7 @@ def write_image(image_path, rgb):
f
.
write
(
img_str
)
f
.
write
(
img_str
)
def
read_image
(
image_path
,
type
=
'rgb'
):
def
read_image
(
image_path
,
type
=
'rgb'
):
with
fopen
(
file_name
,
'r'
)
as
f
:
with
fopen
(
image_path
,
'r'
)
as
f
:
I
=
PIL
.
Image
.
open
(
f
)
I
=
PIL
.
Image
.
open
(
f
)
II
=
np
.
array
(
I
)
II
=
np
.
array
(
I
)
if
type
==
'rgb'
:
if
type
==
'rgb'
:
...
...
research/cognitive_mapping_and_planning/src/graph_utils.py
View file @
020efa74
...
@@ -20,19 +20,20 @@ import numpy as np
...
@@ -20,19 +20,20 @@ import numpy as np
import
networkx
as
nx
import
networkx
as
nx
import
itertools
import
itertools
import
logging
import
logging
from
datasets.nav_env
import
get_path_ids
import
graph_tool
as
gt
import
graph_tool
as
gt
import
graph_tool.topology
import
graph_tool.topology
import
graph_tool.generation
import
graph_tool.generation
import
src.utils
as
utils
import
src.utils
as
utils
# Compute shortest path from all nodes to or from all source nodes
# Compute shortest path from all nodes to or from all source nodes
def
get_distance_node_list
(
gtG
,
source_nodes
,
direction
,
weights
=
None
):
def
get_distance_node_list
(
gtG
,
source_nodes
,
direction
,
weights
=
None
):
gtG_
=
gt
.
Graph
(
gtG
)
gtG_
=
gt
.
Graph
(
gtG
)
v
=
gtG_
.
add_vertex
()
v
=
gtG_
.
add_vertex
()
if
weights
is
not
None
:
if
weights
is
not
None
:
weights
=
gtG_
.
edge_properties
[
weights
]
weights
=
gtG_
.
edge_properties
[
weights
]
for
s
in
source_nodes
:
for
s
in
source_nodes
:
e
=
gtG_
.
add_edge
(
s
,
int
(
v
))
e
=
gtG_
.
add_edge
(
s
,
int
(
v
))
if
weights
is
not
None
:
if
weights
is
not
None
:
...
@@ -110,12 +111,12 @@ def convert_traversible_to_graph(traversible, ff_cost=1., fo_cost=1.,
...
@@ -110,12 +111,12 @@ def convert_traversible_to_graph(traversible, ff_cost=1., fo_cost=1.,
for
i
,
e
in
enumerate
(
g
.
edges
()):
for
i
,
e
in
enumerate
(
g
.
edges
()):
edge_wts
[
e
]
=
edge_wts
[
e
]
*
wts
[
i
]
edge_wts
[
e
]
=
edge_wts
[
e
]
*
wts
[
i
]
# d = edge_wts.get_array()*1.
# d = edge_wts.get_array()*1.
# edge_wts.get_array()[:] = d*wts
# edge_wts.get_array()[:] = d*wts
return
g
,
nodes
return
g
,
nodes
def
label_nodes_with_class
(
nodes_xyt
,
class_maps
,
pix
):
def
label_nodes_with_class
(
nodes_xyt
,
class_maps
,
pix
):
"""
"""
Returns:
Returns:
class_maps__: one-hot class_map for each class.
class_maps__: one-hot class_map for each class.
node_class_label: one-hot class_map for each class, nodes_xyt.shape[0] x n_classes
node_class_label: one-hot class_map for each class, nodes_xyt.shape[0] x n_classes
"""
"""
...
@@ -137,7 +138,7 @@ def label_nodes_with_class(nodes_xyt, class_maps, pix):
...
@@ -137,7 +138,7 @@ def label_nodes_with_class(nodes_xyt, class_maps, pix):
class_maps_one_hot
=
np
.
zeros
(
class_maps
.
shape
,
dtype
=
np
.
bool
)
class_maps_one_hot
=
np
.
zeros
(
class_maps
.
shape
,
dtype
=
np
.
bool
)
node_class_label_one_hot
=
np
.
zeros
((
node_class_label
.
shape
[
0
],
class_maps
.
shape
[
2
]),
dtype
=
np
.
bool
)
node_class_label_one_hot
=
np
.
zeros
((
node_class_label
.
shape
[
0
],
class_maps
.
shape
[
2
]),
dtype
=
np
.
bool
)
for
i
in
range
(
class_maps
.
shape
[
2
]):
for
i
in
range
(
class_maps
.
shape
[
2
]):
class_maps_one_hot
[:,:,
i
]
=
class_maps__
==
i
class_maps_one_hot
[:,:,
i
]
=
class_maps__
==
i
node_class_label_one_hot
[:,
i
]
=
node_class_label
==
i
node_class_label_one_hot
[:,
i
]
=
node_class_label
==
i
return
class_maps_one_hot
,
node_class_label_one_hot
return
class_maps_one_hot
,
node_class_label_one_hot
...
@@ -468,7 +469,7 @@ def rng_next_goal(start_node_ids, batch_size, gtG, rng, max_dist,
...
@@ -468,7 +469,7 @@ def rng_next_goal(start_node_ids, batch_size, gtG, rng, max_dist,
if
compute_path
:
if
compute_path
:
path
=
get_path_ids
(
start_node_ids
[
i
],
end_node_ids
[
i
],
pred_map
)
path
=
get_path_ids
(
start_node_ids
[
i
],
end_node_ids
[
i
],
pred_map
)
paths
.
append
(
path
)
paths
.
append
(
path
)
return
start_node_ids
,
end_node_ids
,
dists
,
pred_maps
,
paths
return
start_node_ids
,
end_node_ids
,
dists
,
pred_maps
,
paths
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment