mirror of
https://github.com/kohya-ss/sd-scripts.git
synced 2026-04-09 06:45:09 +00:00
hope to support python 3.8/3.9
This commit is contained in:
@@ -3,10 +3,11 @@ from dataclasses import (
|
|||||||
asdict,
|
asdict,
|
||||||
dataclass,
|
dataclass,
|
||||||
)
|
)
|
||||||
|
import functools
|
||||||
from textwrap import dedent, indent
|
from textwrap import dedent, indent
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from toolz import curry
|
# from toolz import curry
|
||||||
from typing import (
|
from typing import (
|
||||||
List,
|
List,
|
||||||
Optional,
|
Optional,
|
||||||
@@ -111,13 +112,13 @@ class Blueprint:
|
|||||||
|
|
||||||
|
|
||||||
class ConfigSanitizer:
|
class ConfigSanitizer:
|
||||||
@curry
|
# @curry
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __validate_and_convert_twodim(klass, value: Sequence) -> Tuple:
|
def __validate_and_convert_twodim(klass, value: Sequence) -> Tuple:
|
||||||
Schema(ExactSequence([klass, klass]))(value)
|
Schema(ExactSequence([klass, klass]))(value)
|
||||||
return tuple(value)
|
return tuple(value)
|
||||||
|
|
||||||
@curry
|
# @curry
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __validate_and_convert_scalar_or_twodim(klass, value: Union[float, Sequence]) -> Tuple:
|
def __validate_and_convert_scalar_or_twodim(klass, value: Union[float, Sequence]) -> Tuple:
|
||||||
Schema(Any(klass, ExactSequence([klass, klass])))(value)
|
Schema(Any(klass, ExactSequence([klass, klass])))(value)
|
||||||
@@ -130,7 +131,7 @@ class ConfigSanitizer:
|
|||||||
# subset schema
|
# subset schema
|
||||||
SUBSET_ASCENDABLE_SCHEMA = {
|
SUBSET_ASCENDABLE_SCHEMA = {
|
||||||
"color_aug": bool,
|
"color_aug": bool,
|
||||||
"face_crop_aug_range": __validate_and_convert_twodim(float),
|
"face_crop_aug_range": functools.partial(__validate_and_convert_twodim.__func__, float),
|
||||||
"flip_aug": bool,
|
"flip_aug": bool,
|
||||||
"num_repeats": int,
|
"num_repeats": int,
|
||||||
"random_crop": bool,
|
"random_crop": bool,
|
||||||
@@ -166,7 +167,7 @@ class ConfigSanitizer:
|
|||||||
"enable_bucket": bool,
|
"enable_bucket": bool,
|
||||||
"max_bucket_reso": int,
|
"max_bucket_reso": int,
|
||||||
"min_bucket_reso": int,
|
"min_bucket_reso": int,
|
||||||
"resolution": __validate_and_convert_scalar_or_twodim(int),
|
"resolution": functools.partial(__validate_and_convert_scalar_or_twodim, int),
|
||||||
}
|
}
|
||||||
|
|
||||||
# options handled by argparse but not handled by user config
|
# options handled by argparse but not handled by user config
|
||||||
|
|||||||
Reference in New Issue
Block a user