mirror of
https://github.com/kohya-ss/sd-scripts.git
synced 2026-04-09 06:45:09 +00:00
refactor config parse, feature to output config
This commit is contained in:
20
train_db.py
20
train_db.py
@@ -411,24 +411,6 @@ if __name__ == "__main__":
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.config_file:
|
||||
config_path = args.config_file + ".toml" if not args.config_file.endswith(".toml") else args.config_file
|
||||
if os.path.exists(config_path):
|
||||
print(f"Loading settings from {config_path}...")
|
||||
with open(config_path, "r") as f:
|
||||
config_dict = toml.load(f)
|
||||
|
||||
ignore_nesting_dict = {}
|
||||
for section_name, section_dict in config_dict.items():
|
||||
for key, value in section_dict.items():
|
||||
ignore_nesting_dict[key] = value
|
||||
|
||||
config_args = argparse.Namespace(**ignore_nesting_dict)
|
||||
args = parser.parse_args(namespace=config_args)
|
||||
args.config_file = args.config_file.split(".")[0]
|
||||
print(args.config_file)
|
||||
else:
|
||||
print(f"{config_path} not found.")
|
||||
args = train_util.read_config_from_file(args, parser)
|
||||
|
||||
train(args)
|
||||
|
||||
Reference in New Issue
Block a user