let the pydantic config base model take care of loading configuration from json path

This commit is contained in:
Phil Wang
2022-05-22 14:47:23 -07:00
parent c6629c431a
commit c12e067178
3 changed files with 9 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
import json
from torchvision import transforms as T
from pydantic import BaseModel, validator, root_validator
from typing import List, Iterable, Optional, Union, Tuple, Dict, Any
@@ -111,6 +112,12 @@ class TrainDecoderConfig(BaseModel):
tracker: TrackerConfig
load: DecoderLoadConfig
@classmethod
def from_json_path(cls, json_path):
with open(json_path) as f:
config = json.load(f)
return cls(**config)
@property
def img_preproc(self):
def _get_transformation(transformation_name, **kwargs):