Spaces:
Runtime error
Runtime error
import json | |
def linear_scaling(x): | |
return (x * 255.) / 127.5 - 1. | |
def linear_unscaling(x): | |
return (x + 1.) * 127.5 / 255. | |
def read_json(path): | |
""" | |
:param path (str or os.Path): JSON file path. | |
:return: (Dict): the data in the JSON file. | |
""" | |
with open(path) as f: | |
data = json.load(f) | |
return data | |
def write_json(path, datagroup): | |
""" | |
:param path (str or os.Path): File path for the output JSON file. | |
:param datagroup (Dict): The data which should be dump to the JSON file. | |
:return: void. | |
""" | |
with open(path, "w+") as f: | |
json.dump(datagroup, f) |