Spaces:
Sleeping
Sleeping
Download diffusion_core/configuration_utils.py from hugging-apps/inverse-and-edit: direct link, hf CLI and curl.
- Browser
- Download file 699 Bytes
-
https://huggingface.co/spaces/hugging-apps/inverse-and-edit/resolve/main/diffusion_core/configuration_utils.py
- Command line
-
hf download hf://spaces/hugging-apps/inverse-and-edit/diffusion_core/configuration_utils.py
-
curl -L -o configuration_utils.py https://huggingface.co/spaces/hugging-apps/inverse-and-edit/resolve/main/diffusion_core/configuration_utils.py
699 Bytes
| import functools | |
| import inspect | |
| class MethodStorage(dict): | |
| def register(method_name): | |
| def decorator(method): | |
| method._method_name = method_name | |
| method._is_decorated = True | |
| return method | |
| return decorator | |
| def register_methods(self): | |
| self.registered_methods = {} | |
| for method_name, method in inspect.getmembers(self, predicate=inspect.ismethod): | |
| print(method_name) | |
| if getattr(method, '_is_decorated', False): | |
| self.registered_methods[method._method_name] = method | |
| def __getitem__(self, method_name): | |
| return self.registered_methods[method_name] | |