Spaces:
Sleeping
Sleeping
Download utils/utils.py from modelExperience/resnet101: direct link, hf CLI and curl.
- Browser
- Download file 649 Bytes
-
https://huggingface.co/spaces/modelExperience/resnet101/resolve/refs%2Fpr%2F3/utils/utils.py
- Command line
-
hf download hf://spaces/modelExperience/resnet101@refs/pr/3/utils/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/modelExperience/resnet101/resolve/refs%2Fpr%2F3/utils/utils.py
649 Bytes
| import ruamel.yaml | |
| def read_yaml_file(yaml_path: str, to_dict=True): | |
| """read from yaml file""" | |
| yaml = ruamel.yaml.YAML() | |
| with open(yaml_path, "r") as file: | |
| # yaml_content = yaml.safe_load(file) | |
| yaml_content = yaml.load(file) | |
| yaml_content = dict(yaml_content) if to_dict else yaml_content | |
| return yaml_content | |
| class Singleton(type): | |
| _instances = {} | |
| def __call__(cls, *args, **kwargs): | |
| if cls not in cls._instances: | |
| cls._instances[cls] = super(Singleton, cls).__call__(*args, | |
| **kwargs) | |
| return cls._instances[cls] |