Skip to content

Commit 07dc68a

Browse files
author
Danfei Xu
committed
bug fix for registering backbone architecture
1 parent 5f2d0f3 commit 07dc68a

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

robomimic/models/base_nets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def __init_subclass__(cls, **kwargs):
476476
This also future-proofs us for any additional encoder classes we would
477477
like to add ourselves.
478478
"""
479-
ObsUtils.register_encoder_core(cls)
479+
ObsUtils.register_encoder_backbone(cls)
480480

481481
# dirty hack - re-implement to pass the buck onto subclasses from ABC parent
482482
def output_shape(self, input_shape):

robomimic/models/obs_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def __init__(
9999

100100
# extract only relevant kwargs for this specific backbone
101101
backbone_kwargs = extract_class_init_kwargs_from_dict(
102-
cls = ObsUtils.OBS_ENCODER_CORES[backbone_class],
102+
cls = ObsUtils.OBS_ENCODER_BACKBONES[backbone_class],
103103
dic=backbone_kwargs, copy=True)
104104

105105
# visual backbone

robomimic/utils/obs_utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@
4141
# in their config, without having to manually register their class internally.
4242
# This also future-proofs us for any additional encoder / randomizer classes we would
4343
# like to add ourselves.
44-
OBS_ENCODER_CORES = {"None": None} # Include default None
45-
OBS_RANDOMIZERS = {"None": None} # Include default None
44+
OBS_ENCODER_CORES = {"None": None} # Per-modality core net as defined in obs_cores.py, e.g., "VisualCore"
45+
OBS_RANDOMIZERS = {"None": None} # Obs randomizer defined in obs_cores.py, e.g., "CropRandomizer"
46+
OBS_ENCODER_BACKBONES = {"None": None} # Architecture backbones for encoding obervation, e.g., "ResNet18Conv"
4647

4748

4849
def register_obs_key(target_class):
@@ -59,6 +60,10 @@ def register_randomizer(target_class):
5960
assert target_class not in OBS_RANDOMIZERS, f"Already registered obs randomizer {target_class}!"
6061
OBS_RANDOMIZERS[target_class.__name__] = target_class
6162

63+
def register_encoder_backbone(target_class):
64+
assert target_class not in OBS_ENCODER_BACKBONES, f"Already registered obs encoder backbone {target_class}!"
65+
OBS_ENCODER_BACKBONES[target_class.__name__] = target_class
66+
6267

6368
class ObservationKeyToModalityDict(dict):
6469
"""

0 commit comments

Comments
 (0)