Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:inverted-ai/invertedai into docu…
Browse files Browse the repository at this point in the history
…mentation
  • Loading branch information
Ruishenl committed Oct 21, 2022
2 parents aab7805 + 168ee3e commit 4994227
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/Demo_Drive_REST.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
+ f"Wrong-way rate: {100*np.array([inf.wrong_way for inf in response.infractions]).mean():.2f}%"
)

image = response.bird_view.decode()
image = response.birdview.decode()
frames.append(image)
im = PImage.fromarray(image)
imageio.mimsave("iai-drive.gif", np.array(frames), format="GIF-PIL")
10 changes: 5 additions & 5 deletions invertedai/api/drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DriveResponse:
"""
agent_states: List[AgentState] #: Predicted states for all agents at the next time step.
recurrent_states: List[RecurrentState] #: To pass to :func:`iai.drive` at the subsequent time step.
bird_view: Optional[Image] #: If `get_birdview` was set, this contains the resulting image.
birdview: Optional[Image] #: If `get_birdview` was set, this contains the resulting image.
infractions: Optional[List[InfractionIndicators]] #: If `get_infractions` was set, they are returned here.
is_inside_supported_area: List[bool] #: For each agent, indicates whether the predicted state is inside supported area.

Expand Down Expand Up @@ -74,13 +74,13 @@ def drive(
if should_use_mock_api():
agent_states = [mock_update_agent_state(s) for s in agent_states]
present_mask = [True for _ in agent_states]
bird_view = get_mock_birdview()
birdview = get_mock_birdview()
infractions = get_mock_infractions(len(agent_states))
response = DriveResponse(
agent_states=agent_states,
is_inside_supported_area=present_mask,
recurrent_states=recurrent_states,
bird_view=bird_view,
birdview=birdview,
infractions=infractions,
)
return response
Expand All @@ -100,7 +100,7 @@ def _tolist(input_data: List):
agent_attributes=[state.tolist() for state in agent_attributes],
recurrent_states=[r.packed for r in recurrent_states],
traffic_lights_states=traffic_lights_states,
get_birdviews=get_birdview,
get_birdview=get_birdview,
get_infractions=get_infractions,
random_seed=random_seed,
)
Expand All @@ -114,7 +114,7 @@ def _tolist(input_data: List):
response = DriveResponse(
agent_states=[AgentState.fromlist(state) for state in response["agent_states"]],
recurrent_states=[RecurrentState(r) for r in response["recurrent_states"]],
bird_view=Image(response["bird_view"]) if response['bird_view'] is not None else None,
birdview=Image(response["birdview"]) if response['birdview'] is not None else None,
infractions=[
InfractionIndicators(*infractions)
for infractions in response["infraction_indicators"]
Expand Down
4 changes: 2 additions & 2 deletions invertedai/cosimulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def npc_states(self) -> List[AgentState]:
The predictions for ego agents are excluded.
"""
npc_states = []
for (i, s) in self._agent_states:
for (i, s) in enumerate(self._agent_states):
if not self._ego_agent_mask[i]:
npc_states.append(s)
return npc_states
Expand Down Expand Up @@ -148,7 +148,7 @@ def step(self, current_ego_agent_states: List[AgentState]) -> None:
[inf.wrong_way for inf in response.infractions],
)
if self._render_birdview:
self._birdview = response.bird_view
self._birdview = response.birdview
self._time_step += 1

def _update_ego_states(self, ego_agent_states):
Expand Down

0 comments on commit 4994227

Please sign in to comment.