|
|
|
|
@@ -39,11 +39,11 @@ class TrainSplitConfig(BaseModel):
|
|
|
|
|
test: float = 0.1
|
|
|
|
|
|
|
|
|
|
@model_validator(mode = 'after')
|
|
|
|
|
def validate_all(self, m):
|
|
|
|
|
def validate_all(self):
|
|
|
|
|
actual_sum = sum([*dict(self).values()])
|
|
|
|
|
if actual_sum != 1.:
|
|
|
|
|
raise ValueError(f'{dict(self).keys()} must sum to 1.0. Found: {actual_sum}')
|
|
|
|
|
return self
|
|
|
|
|
raise ValueError(f'{fields.keys()} must sum to 1.0. Found: {actual_sum}')
|
|
|
|
|
return fields
|
|
|
|
|
|
|
|
|
|
class TrackerLogConfig(BaseModel):
|
|
|
|
|
log_type: str = 'console'
|
|
|
|
|
@@ -90,7 +90,7 @@ class TrackerConfig(BaseModel):
|
|
|
|
|
data_path: str = '.tracker_data'
|
|
|
|
|
overwrite_data_path: bool = False
|
|
|
|
|
log: TrackerLogConfig
|
|
|
|
|
load: Optional[TrackerLoadConfig] = None
|
|
|
|
|
load: Optional[TrackerLoadConfig]
|
|
|
|
|
save: Union[List[TrackerSaveConfig], TrackerSaveConfig]
|
|
|
|
|
|
|
|
|
|
def create(self, full_config: BaseModel, extra_config: dict, dummy_mode: bool = False) -> Tracker:
|
|
|
|
|
@@ -278,9 +278,9 @@ class DecoderConfig(BaseModel):
|
|
|
|
|
extra = "allow"
|
|
|
|
|
|
|
|
|
|
class DecoderDataConfig(BaseModel):
|
|
|
|
|
webdataset_base_url: str # path to a webdataset with jpg images
|
|
|
|
|
img_embeddings_url: Optional[str] = None # path to .npy files with embeddings
|
|
|
|
|
text_embeddings_url: Optional[str] = None # path to .npy files with embeddings
|
|
|
|
|
webdataset_base_url: str # path to a webdataset with jpg images
|
|
|
|
|
img_embeddings_url: Optional[str] # path to .npy files with embeddings
|
|
|
|
|
text_embeddings_url: Optional[str] # path to .npy files with embeddings
|
|
|
|
|
num_workers: int = 4
|
|
|
|
|
batch_size: int = 64
|
|
|
|
|
start_shard: int = 0
|
|
|
|
|
@@ -347,14 +347,11 @@ class TrainDecoderConfig(BaseModel):
|
|
|
|
|
def from_json_path(cls, json_path):
|
|
|
|
|
with open(json_path) as f:
|
|
|
|
|
config = json.load(f)
|
|
|
|
|
print(config)
|
|
|
|
|
return cls(**config)
|
|
|
|
|
|
|
|
|
|
@model_validator(mode = 'after')
|
|
|
|
|
def check_has_embeddings(self, m):
|
|
|
|
|
def check_has_embeddings(cls, values):
|
|
|
|
|
# Makes sure that enough information is provided to get the embeddings specified for training
|
|
|
|
|
values = dict(self)
|
|
|
|
|
|
|
|
|
|
data_config, decoder_config = values.get('data'), values.get('decoder')
|
|
|
|
|
|
|
|
|
|
if not exists(data_config) or not exists(decoder_config):
|
|
|
|
|
@@ -379,4 +376,4 @@ class TrainDecoderConfig(BaseModel):
|
|
|
|
|
if text_emb_url:
|
|
|
|
|
assert using_text_embeddings, "Text embeddings are being loaded, but text embeddings are not being conditioned on. This will slow down the dataloader for no reason."
|
|
|
|
|
|
|
|
|
|
return m
|
|
|
|
|
return values
|
|
|
|
|
|