Files
edenartlab-sd-lora-trainer/trainer/utils/json_stuff.py
T
2024-04-03 23:53:37 -07:00

14 lines
366 B
Python

import ujson
import os
def save_as_json(dictionary_or_list, filename: str):
with open(filename, "w") as fp:
ujson.dump(dictionary_or_list, fp, indent=4)
def load_json(filename: str):
assert os.path.exists(filename), f"Could not find json file: {filename}"
with open(filename) as json_file:
data = ujson.load(json_file)
return data