CoolFace
Apppublic

KitHung/InternVL

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
utils.py25 linesDownload Raw Back to root
1import os2import json3import logging4from datetime import datetime5 6 7def load_json(file_name: str):8    if isinstance(file_name, str) and file_name.endswith("json"):9        with open(file_name, 'r') as file:10            data = json.load(file)11    else:12        raise ValueError("The file path you passed in is not a json file path.")13    14    return data15 16def init_logger(outputs_dir):17    current_time = datetime.now().strftime("%b%d_%H-%M-%S")18    os.makedirs(os.path.join(outputs_dir, "logs"), exist_ok=True)19    log_path = os.path.join(outputs_dir, "logs", "{}.txt".format(current_time))20    logging.basicConfig(21        level=logging.INFO,22        format="%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s || %(message)s",23        handlers=[logging.StreamHandler(), logging.FileHandler(log_path)],24    )25