Skip to content

Commit

Permalink
Merge pull request #219 from argoai/use-config-for-constants
Browse files Browse the repository at this point in the history
Increase readability by placing global constants in a config
  • Loading branch information
johnwlambert committed May 11, 2021
2 parents 6c360f3 + 57e4419 commit 8c35ab8
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 3 deletions.
Empty file added argoverse/config/__init__.py
Empty file.
54 changes: 54 additions & 0 deletions argoverse/config/argoverse1.1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
SensorDatasetConfig:
_target_: argoverse.sensor_dataset_config.SensorDatasetConfig
dataset_name: argoverse1.1
ring_cam_fps: 30
stereo_cam_fps: 5

# all ring cameras are `landscape` aspect ratio
sensors:
_target_: argoverse.sensor_dataset_config.SensorSuiteConfig

ring_front_center:
_target_: argoverse.sensor_dataset_config.SensorConfig
img_height: 1200
img_width: 1920

ring_front_left:
_target_: argoverse.sensor_dataset_config.SensorConfig
img_height: 1200
img_width: 1920

ring_front_right:
_target_: argoverse.sensor_dataset_config.SensorConfig
img_height: 1200
img_width: 1920

ring_side_left:
_target_: argoverse.sensor_dataset_config.SensorConfig
img_height: 1200
img_width: 1920

ring_side_right:
_target_: argoverse.sensor_dataset_config.SensorConfig
img_height: 1200
img_width: 1920

ring_rear_left:
_target_: argoverse.sensor_dataset_config.SensorConfig
img_height: 1200
img_width: 1920

ring_rear_right:
_target_: argoverse.sensor_dataset_config.SensorConfig
img_height: 1200
img_width: 1920

stereo_front_right:
_target_: argoverse.sensor_dataset_config.SensorConfig
img_height: 2056
img_width: 2464

stereo_front_left:
_target_: argoverse.sensor_dataset_config.SensorConfig
img_height: 2056
img_width: 2464
41 changes: 41 additions & 0 deletions argoverse/sensor_dataset_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from typing import NamedTuple, Optional

import hydra
from hydra.utils import instantiate


class SensorConfig(NamedTuple):
"""Image dimensions for each sensor are provided in pixels."""

img_height: int
img_width: int


class SensorSuiteConfig(NamedTuple):
"""Contains information about image dimensions for each sensor."""

ring_front_center: SensorConfig
ring_front_left: SensorConfig
ring_front_right: SensorConfig
ring_side_left: SensorConfig
ring_side_right: SensorConfig
ring_rear_left: SensorConfig
ring_rear_right: SensorConfig
stereo_front_right: Optional[SensorConfig]
stereo_front_left: Optional[SensorConfig]


class SensorDatasetConfig(NamedTuple):
"""Global constants regarding frame rate and image dimensions."""

dataset_name: str
ring_cam_fps: int
stereo_cam_fps: int
sensors: SensorSuiteConfig


DATASET_NAME = "argoverse1.1"

with hydra.initialize_config_module(config_module="argoverse.config"):
cfg = hydra.compose(config_name=f"{DATASET_NAME}.yaml")
ArgoverseConfig: SensorDatasetConfig = instantiate(cfg.SensorDatasetConfig)
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

setup(
name="argoverse",
version="1.0.0",
version="1.0.1",
description="",
long_description=long_description,
url="https://www.argoverse.org",
Expand All @@ -52,6 +52,9 @@
"colour",
"descartes",
"imageio",
"h5py",
"hydra-core==1.1.0dev6",
"lap",
"matplotlib",
"motmetrics==1.1.3",
"numpy==1.19",
Expand All @@ -64,8 +67,6 @@
"shapely",
"sklearn",
"typing_extensions",
"h5py",
"lap",
],
# for older pip version, use with --process-dependency-links
dependency_links=["git+https://github.com/daavoo/pyntcloud#egg=pyntcloud-0.1.0"],
Expand Down

0 comments on commit 8c35ab8

Please sign in to comment.