Spaces:
Runtime error
Runtime error
Download lib/cfg_holder.py from ElixirRod/Versatile-Diffusion: direct link, hf CLI and curl.
- Browser
- Download file 673 Bytes
-
https://huggingface.co/spaces/ElixirRod/Versatile-Diffusion/resolve/main/lib/cfg_holder.py
- Command line
-
hf download hf://spaces/ElixirRod/Versatile-Diffusion/lib/cfg_holder.py
-
curl -L -o cfg_holder.py https://huggingface.co/spaces/ElixirRod/Versatile-Diffusion/resolve/main/lib/cfg_holder.py
673 Bytes
| import copy | |
| def singleton(class_): | |
| instances = {} | |
| def getinstance(*args, **kwargs): | |
| if class_ not in instances: | |
| instances[class_] = class_(*args, **kwargs) | |
| return instances[class_] | |
| return getinstance | |
| ############## | |
| # cfg_holder # | |
| ############## | |
| class cfg_unique_holder(object): | |
| def __init__(self): | |
| self.cfg = None | |
| # this is use to track the main codes. | |
| self.code = set() | |
| def save_cfg(self, cfg): | |
| self.cfg = copy.deepcopy(cfg) | |
| def add_code(self, code): | |
| """ | |
| A new main code is reached and | |
| its name is added. | |
| """ | |
| self.code.add(code) | |