Spaces:
Runtime error
Runtime error
File size: 621 Bytes
2a92dc2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
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) |