Skip to content

Commit 865fd98

Browse files
authored
[FIX] refactor scripts folder (#120)
* refactor scripts * update CI
1 parent 6f94ba0 commit 865fd98

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+499
-527
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ The toolbox supports the most comprehensive 6 datasets \& benchmarks and 10+ pop
3434
The toolbox supports the most advanced high-quality navigation dataset, InternData-N1, which includes 3k+ scenes and 830k VLN data covering diverse embodiments and scenes, and the first dual-system navigation foundation model with leading performance on all the benchmarks and zero-shot generalization capability in the real world, InternVLA-N1.
3535

3636
## 🔥
37-
- [2025/10] Add a simple [inference-only demo](scripts/eval/inference_only_demo.ipynb) of InternVLA-N1.
37+
- [2025/10] Add a simple [inference-only demo](scripts/notebooks/inference_only_demo.ipynb) of InternVLA-N1.
3838
- [2025/10] InternVLA-N1 [technique report](https://internrobotics.github.io/internvla-n1.github.io/static/pdfs/InternVLA_N1.pdf) is released. Please check our [homepage](https://internrobotics.github.io/internvla-n1.github.io/).
39-
- [2025/09] Real-world deployment code of InternVLA-N1 is released.- [2025/09] Real-world deployment code of InternVLA-N1 is released.
39+
- [2025/09] Real-world deployment code of InternVLA-N1 is released.
4040
- [2025/07] We are hosting 🏆IROS 2025 Grand Challenge, stay tuned at [official website](https://internrobotics.shlab.org.cn/challenge/2025/).
4141
- [2025/07] InternNav v0.1.1 released.
4242

-124 KB
Binary file not shown.
-73.9 KB
Binary file not shown.
File renamed without changes.

internnav/habitat_extensions/evaluator_single.py renamed to internnav/projects/habitat_extensions/evaluator_single.py

Lines changed: 209 additions & 194 deletions
Large diffs are not rendered by default.
File renamed without changes.

internnav/habitat_extensions/maps.py renamed to internnav/projects/habitat_extensions/maps.py

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
MAP_SHORTEST_PATH_WAYPOINT = 14
2929

3030
TOP_DOWN_MAP_COLORS = np.full((256, 3), 150, dtype=np.uint8)
31-
TOP_DOWN_MAP_COLORS[15:] = cv2.applyColorMap(
32-
np.arange(241, dtype=np.uint8), cv2.COLORMAP_JET
33-
).squeeze(1)[:, ::-1]
31+
TOP_DOWN_MAP_COLORS[15:] = cv2.applyColorMap(np.arange(241, dtype=np.uint8), cv2.COLORMAP_JET).squeeze(1)[:, ::-1]
3432
TOP_DOWN_MAP_COLORS[MAP_INVALID_POINT] = [255, 255, 255] # White
3533
TOP_DOWN_MAP_COLORS[MAP_VALID_POINT] = [150, 150, 150] # Light Grey
3634
TOP_DOWN_MAP_COLORS[MAP_BORDER_INDICATOR] = [50, 50, 50] # Grey
@@ -73,9 +71,7 @@ def colorize_top_down_map(
7371
# Only desaturate valid points as only valid points get revealed
7472
desat_mask = top_down_map != MAP_INVALID_POINT
7573

76-
_map[desat_mask] = (
77-
_map * fog_of_war_desat_values[fog_of_war_mask]
78-
).astype(np.uint8)[desat_mask]
74+
_map[desat_mask] = (_map * fog_of_war_desat_values[fog_of_war_mask]).astype(np.uint8)[desat_mask]
7975

8076
return _map
8177

@@ -205,9 +201,7 @@ def draw_reference_path(
205201
pt_from = pt_to
206202

207203
for pt in shortest_path_points:
208-
drawpoint(
209-
img, (pt[1], pt[0]), MAP_SHORTEST_PATH_WAYPOINT, meters_per_px
210-
)
204+
drawpoint(img, (pt[1], pt[0]), MAP_SHORTEST_PATH_WAYPOINT, meters_per_px)
211205

212206

213207
def draw_straight_shortest_path_points(
@@ -219,10 +213,7 @@ def draw_straight_shortest_path_points(
219213
"""Draws the shortest path from start to goal assuming a standard
220214
discrete action space.
221215
"""
222-
shortest_path_points = [
223-
habitat_maps.to_grid(p[2], p[0], img.shape[0:2], sim)[::-1]
224-
for p in shortest_path_points
225-
]
216+
shortest_path_points = [habitat_maps.to_grid(p[2], p[0], img.shape[0:2], sim)[::-1] for p in shortest_path_points]
226217

227218
habitat_maps.draw_path(
228219
img,
@@ -232,9 +223,7 @@ def draw_straight_shortest_path_points(
232223
)
233224

234225

235-
def draw_source_and_target(
236-
img: np.ndarray, sim: Simulator, episode: VLNEpisode, meters_per_px: float
237-
) -> None:
226+
def draw_source_and_target(img: np.ndarray, sim: Simulator, episode: VLNEpisode, meters_per_px: float) -> None:
238227
s_x, s_y = habitat_maps.to_grid(
239228
episode.start_position[2],
240229
episode.start_position[0],
@@ -285,18 +274,14 @@ def get_nearest_node(graph: nx.Graph, current_position: List[float]) -> str:
285274
for node in graph:
286275
node_pos = graph.nodes[node]["position"]
287276
node_pos = np.take(node_pos, (0, 2))
288-
cur_dist = np.linalg.norm(
289-
np.array(node_pos) - np.array(current_position), ord=2
290-
)
277+
cur_dist = np.linalg.norm(np.array(node_pos) - np.array(current_position), ord=2)
291278
if cur_dist < dist:
292279
dist = cur_dist
293280
nearest = node
294281
return nearest
295282

296283

297-
def update_nearest_node(
298-
graph: nx.Graph, nearest_node: str, current_position: np.ndarray
299-
) -> str:
284+
def update_nearest_node(graph: nx.Graph, nearest_node: str, current_position: np.ndarray) -> str:
300285
"""Determine the closest MP3D node to the agent's current position as
301286
given by a [x,z] position vector. The selected node must be reachable
302287
from the previous MP3D node as specified in the nav-graph edges.
@@ -309,9 +294,7 @@ def update_nearest_node(
309294
for node in [nearest_node] + [e[1] for e in graph.edges(nearest_node)]:
310295
node_pos = graph.nodes[node]["position"]
311296
node_pos = np.take(node_pos, (0, 2))
312-
cur_dist = np.linalg.norm(
313-
np.array(node_pos) - np.array(current_position), ord=2
314-
)
297+
cur_dist = np.linalg.norm(np.array(node_pos) - np.array(current_position), ord=2)
315298
if cur_dist < dist:
316299
dist = cur_dist
317300
nearest = node
@@ -325,18 +308,14 @@ def draw_mp3d_nodes(
325308
graph: nx.Graph,
326309
meters_per_px: float,
327310
) -> None:
328-
n = get_nearest_node(
329-
graph, (episode.start_position[0], episode.start_position[2])
330-
)
311+
n = get_nearest_node(graph, (episode.start_position[0], episode.start_position[2]))
331312
starting_height = graph.nodes[n]["position"][1]
332313
for node in graph:
333314
pos = graph.nodes[node]["position"]
334315

335316
# no obvious way to differentiate between floors. Use this for now.
336317
if abs(pos[1] - starting_height) < 1.0:
337-
r_x, r_y = habitat_maps.to_grid(
338-
pos[2], pos[0], img.shape[0:2], sim
339-
)
318+
r_x, r_y = habitat_maps.to_grid(pos[2], pos[0], img.shape[0:2], sim)
340319

341320
# only paint if over a valid point
342321
if img[r_x, r_y]:
@@ -388,4 +367,4 @@ def image_resize(
388367
img = img.permute(0, 1, 3, 4, 2)
389368
if no_batch_dim:
390369
img = img.squeeze(dim=0) # Removes the batch dimension
391-
return img
370+
return img

internnav/habitat_extensions/measures.py renamed to internnav/projects/habitat_extensions/measures.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
1-
import gzip
2-
import json
3-
import pickle
41
from typing import Any, List, Union
52

63
import numpy as np
4+
75
# from dtw import dtw
86
# from fastdtw import fastdtw
97
# from habitat.config import Config
10-
from habitat.core.dataset import Episode
11-
from habitat.core.embodied_task import Action, EmbodiedTask, Measure
12-
from habitat.core.logging import logger
8+
from habitat.core.embodied_task import EmbodiedTask, Measure
139
from habitat.core.registry import registry
1410
from habitat.core.simulator import Simulator
1511
from habitat.core.utils import try_cv2_import
16-
from habitat.tasks.nav.nav import DistanceToGoal, Success
17-
from habitat.tasks.utils import cartesian_to_polar
18-
from habitat.utils.geometry_utils import quaternion_rotate_vector
19-
from habitat.utils.visualizations import fog_of_war
20-
from habitat.utils.visualizations import maps as habitat_maps
12+
from habitat.tasks.nav.nav import DistanceToGoal
2113
from numpy import ndarray
2214

2315
# from utils import maps
@@ -26,9 +18,7 @@
2618
cv2 = try_cv2_import()
2719

2820

29-
def euclidean_distance(
30-
pos_a: Union[List[float], ndarray], pos_b: Union[List[float], ndarray]
31-
) -> float:
21+
def euclidean_distance(pos_a: Union[List[float], ndarray], pos_b: Union[List[float], ndarray]) -> float:
3222
return np.linalg.norm(np.array(pos_b) - np.array(pos_a), ord=2)
3323

3424

@@ -54,9 +44,7 @@ def reset_metric(self, *args: Any, **kwargs: Any):
5444

5545
def update_metric(self, *args: Any, **kwargs: Any):
5646
current_position = self._sim.get_agent_state().position
57-
self._metric += euclidean_distance(
58-
current_position, self._previous_position
59-
)
47+
self._metric += euclidean_distance(current_position, self._previous_position)
6048
self._previous_position = current_position
6149

6250

@@ -73,16 +61,12 @@ def _get_uuid(self, *args: Any, **kwargs: Any) -> str:
7361
return self.cls_uuid
7462

7563
def reset_metric(self, *args: Any, task: EmbodiedTask, **kwargs: Any):
76-
task.measurements.check_measure_dependencies(
77-
self.uuid, [DistanceToGoal.cls_uuid]
78-
)
64+
task.measurements.check_measure_dependencies(self.uuid, [DistanceToGoal.cls_uuid])
7965
self._metric = float("inf")
8066
self.update_metric(task=task)
8167

8268
def update_metric(self, *args: Any, task: EmbodiedTask, **kwargs: Any):
83-
distance_to_target = task.measurements.measures[
84-
DistanceToGoal.cls_uuid
85-
].get_metric()
69+
distance_to_target = task.measurements.measures[DistanceToGoal.cls_uuid].get_metric()
8670
self._metric = min(self._metric, distance_to_target)
8771

8872

@@ -105,9 +89,7 @@ def _get_uuid(self, *args: Any, **kwargs: Any) -> str:
10589
return self.cls_uuid
10690

10791
def reset_metric(self, *args: Any, task: EmbodiedTask, **kwargs: Any):
108-
task.measurements.check_measure_dependencies(
109-
self.uuid, [DistanceToGoal.cls_uuid]
110-
)
92+
task.measurements.check_measure_dependencies(self.uuid, [DistanceToGoal.cls_uuid])
11193
self._metric = 0.0
11294
self.update_metric(task=task)
11395

0 commit comments

Comments
 (0)