directory to look for config files
This commit is contained in:
@@ -20,12 +20,11 @@ import logging
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
version_config_list = [
|
version_config_list: list = [
|
||||||
"v1/32k.json",
|
os.path.join(root, file)
|
||||||
"v1/40k.json",
|
for root, dirs, files in os.walk(os.path.dirname(os.path.abspath(__file__)))
|
||||||
"v1/48k.json",
|
for file in files
|
||||||
"v2/48k.json",
|
if file.endswith(".json")
|
||||||
"v2/32k.json",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -62,11 +61,10 @@ class Config:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load_config_json() -> dict:
|
def load_config_json() -> dict:
|
||||||
d = {}
|
return {
|
||||||
for config_file in version_config_list:
|
config_file: json.load(open(config_file, "r"))
|
||||||
with open(f"configs/{config_file}", "r") as f:
|
for config_file in version_config_list
|
||||||
d[config_file] = json.load(f)
|
}
|
||||||
return d
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def arg_parse() -> tuple:
|
def arg_parse() -> tuple:
|
||||||
@@ -120,18 +118,15 @@ class Config:
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def use_fp32_config(self):
|
def use_fp32_config(self) -> None:
|
||||||
for config_file in version_config_list:
|
for config_file, data in self.json_config.items():
|
||||||
self.json_config[config_file]["train"]["fp16_run"] = False
|
try:
|
||||||
with open(f"configs/{config_file}", "r") as f:
|
data["train"]["fp16_run"] = False
|
||||||
strr = f.read().replace("true", "false")
|
with open(config_file, "w") as json_file:
|
||||||
with open(f"configs/{config_file}", "w") as f:
|
json.dump(data, json_file, indent=4)
|
||||||
f.write(strr)
|
except Exception as e:
|
||||||
with open("infer/modules/train/preprocess.py", "r") as f:
|
logger.info(f"Error updating {config_file}: {str(e)}")
|
||||||
strr = f.read().replace("3.7", "3.0")
|
logger.info("overwrite configs.json")
|
||||||
with open("infer/modules/train/preprocess.py", "w") as f:
|
|
||||||
f.write(strr)
|
|
||||||
print("overwrite preprocess and configs.json")
|
|
||||||
|
|
||||||
def device_config(self) -> tuple:
|
def device_config(self) -> tuple:
|
||||||
if torch.cuda.is_available():
|
if torch.cuda.is_available():
|
||||||
|
|||||||
Reference in New Issue
Block a user