mirror of
https://github.com/lucidrains/DALLE2-pytorch.git
synced 2026-02-15 13:24:18 +01:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c56336a104 |
@@ -1,6 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
from torchvision import transforms as T
|
from torchvision import transforms as T
|
||||||
from pydantic import BaseModel, validator, root_validator
|
from pydantic import BaseModel, validator, model_validator
|
||||||
from typing import List, Optional, Union, Tuple, Dict, Any, TypeVar
|
from typing import List, Optional, Union, Tuple, Dict, Any, TypeVar
|
||||||
|
|
||||||
from x_clip import CLIP as XCLIP
|
from x_clip import CLIP as XCLIP
|
||||||
@@ -38,9 +38,9 @@ class TrainSplitConfig(BaseModel):
|
|||||||
val: float = 0.15
|
val: float = 0.15
|
||||||
test: float = 0.1
|
test: float = 0.1
|
||||||
|
|
||||||
@root_validator
|
@model_validator(mode = 'after')
|
||||||
def validate_all(cls, fields):
|
def validate_all(self):
|
||||||
actual_sum = sum([*fields.values()])
|
actual_sum = sum([*dict(self).values()])
|
||||||
if actual_sum != 1.:
|
if actual_sum != 1.:
|
||||||
raise ValueError(f'{fields.keys()} must sum to 1.0. Found: {actual_sum}')
|
raise ValueError(f'{fields.keys()} must sum to 1.0. Found: {actual_sum}')
|
||||||
return fields
|
return fields
|
||||||
@@ -59,6 +59,7 @@ class TrackerLogConfig(BaseModel):
|
|||||||
kwargs = self.dict()
|
kwargs = self.dict()
|
||||||
return create_logger(self.log_type, data_path, **kwargs)
|
return create_logger(self.log_type, data_path, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class TrackerLoadConfig(BaseModel):
|
class TrackerLoadConfig(BaseModel):
|
||||||
load_from: Optional[str] = None
|
load_from: Optional[str] = None
|
||||||
only_auto_resume: bool = False # Only attempt to load if the logger is auto-resuming
|
only_auto_resume: bool = False # Only attempt to load if the logger is auto-resuming
|
||||||
@@ -348,7 +349,7 @@ class TrainDecoderConfig(BaseModel):
|
|||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
return cls(**config)
|
return cls(**config)
|
||||||
|
|
||||||
@root_validator
|
@model_validator(mode = 'after')
|
||||||
def check_has_embeddings(cls, values):
|
def check_has_embeddings(cls, values):
|
||||||
# Makes sure that enough information is provided to get the embeddings specified for training
|
# Makes sure that enough information is provided to get the embeddings specified for training
|
||||||
data_config, decoder_config = values.get('data'), values.get('decoder')
|
data_config, decoder_config = values.get('data'), values.get('decoder')
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
__version__ = '1.14.2'
|
__version__ = '1.15.0'
|
||||||
|
|||||||
Reference in New Issue
Block a user