|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| """Configurations for loading checkpoints."""
|
|
|
| import dataclasses
|
| from typing import Dict, Optional
|
|
|
| import numpy as np
|
|
|
| from official.projects.centernet.utils.checkpoints import config_classes
|
|
|
| Conv2DBNCFG = config_classes.Conv2DBNCFG
|
| HeadConvCFG = config_classes.HeadConvCFG
|
| ResidualBlockCFG = config_classes.ResidualBlockCFG
|
| HourglassCFG = config_classes.HourglassCFG
|
|
|
|
|
| @dataclasses.dataclass
|
| class BackboneConfigData:
|
| """Backbone Config."""
|
|
|
| weights_dict: Optional[Dict[str, np.ndarray]] = dataclasses.field(
|
| repr=False, default=None)
|
|
|
| def get_cfg_list(self, name):
|
| """Get list of block configs for the module."""
|
|
|
| if name == 'hourglass104_512':
|
| return [
|
|
|
| Conv2DBNCFG(
|
| weights_dict=self.weights_dict['downsample_input']['conv_block']),
|
| ResidualBlockCFG(
|
| weights_dict=self.weights_dict['downsample_input'][
|
| 'residual_block']),
|
|
|
| HourglassCFG(
|
| weights_dict=self.weights_dict['hourglass_network']['0']),
|
| Conv2DBNCFG(
|
| weights_dict=self.weights_dict['output_conv']['0']),
|
|
|
| Conv2DBNCFG(
|
| weights_dict=self.weights_dict['intermediate_conv1']['0']),
|
| Conv2DBNCFG(
|
| weights_dict=self.weights_dict['intermediate_conv2']['0']),
|
| ResidualBlockCFG(
|
| weights_dict=self.weights_dict['intermediate_residual']['0']),
|
|
|
| HourglassCFG(
|
| weights_dict=self.weights_dict['hourglass_network']['1']),
|
| Conv2DBNCFG(
|
| weights_dict=self.weights_dict['output_conv']['1']),
|
| ]
|
|
|
| elif name == 'extremenet':
|
| return [
|
|
|
| Conv2DBNCFG(
|
| weights_dict=self.weights_dict['downsample_input']['conv_block']),
|
| ResidualBlockCFG(
|
| weights_dict=self.weights_dict['downsample_input'][
|
| 'residual_block']),
|
|
|
| HourglassCFG(
|
| weights_dict=self.weights_dict['hourglass_network']['0']),
|
| Conv2DBNCFG(
|
| weights_dict=self.weights_dict['output_conv']['0']),
|
|
|
| Conv2DBNCFG(
|
| weights_dict=self.weights_dict['intermediate_conv1']['0']),
|
| Conv2DBNCFG(
|
| weights_dict=self.weights_dict['intermediate_conv2']['0']),
|
| ResidualBlockCFG(
|
| weights_dict=self.weights_dict['intermediate_residual']['0']),
|
|
|
| HourglassCFG(
|
| weights_dict=self.weights_dict['hourglass_network']['1']),
|
| Conv2DBNCFG(
|
| weights_dict=self.weights_dict['output_conv']['1']),
|
| ]
|
|
|
|
|
| @dataclasses.dataclass
|
| class HeadConfigData:
|
| """Head Config."""
|
|
|
| weights_dict: Optional[Dict[str, np.ndarray]] = dataclasses.field(
|
| repr=False, default=None)
|
|
|
| def get_cfg_list(self, name):
|
| if name == 'detection_2d':
|
| return [
|
| HeadConvCFG(weights_dict=self.weights_dict['object_center']['0']),
|
| HeadConvCFG(weights_dict=self.weights_dict['object_center']['1']),
|
| HeadConvCFG(weights_dict=self.weights_dict['box.Soffset']['0']),
|
| HeadConvCFG(weights_dict=self.weights_dict['box.Soffset']['1']),
|
| HeadConvCFG(weights_dict=self.weights_dict['box.Sscale']['0']),
|
| HeadConvCFG(weights_dict=self.weights_dict['box.Sscale']['1'])
|
| ]
|
|
|