https://github.com/lartpang/registerit
A more flexible register for the DeepLearning project.
https://github.com/lartpang/registerit
deeplearning-tool registry tool utility
Last synced: 9 months ago
JSON representation
A more flexible register for the DeepLearning project.
- Host: GitHub
- URL: https://github.com/lartpang/registerit
- Owner: lartpang
- License: mit
- Created: 2021-05-22T12:11:49.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-07-04T11:37:18.000Z (almost 4 years ago)
- Last Synced: 2025-08-20T04:27:52.729Z (9 months ago)
- Topics: deeplearning-tool, registry, tool, utility
- Language: Python
- Homepage:
- Size: 17.6 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RegisterIt
Register it: A more flexible register for the DeepLearning project.
The registry that provides name -> object mapping, to support classes and functions.
## Install
```shell
pip install register_it
```
## Usage
To create a registry (e.g. a class registry and a function registry):
```python
DATASETS = Registry(name="dataset")
EVALUATE = Registry(name="evaluate")
```
To register an object:
```python
@DATASETS.register(name='mymodule')
class MyModule(*args, **kwargs):
...
@EVALUATE.register(name='myfunc')
def my_func(*args, **kwargs):
...
```
Or:
```python
DATASETS.register(name='mymodule', obj=MyModule)
EVALUATE.register(name='myfunc', obj=my_func)
```
To construct an object of the class or the function:
```python
DATASETS = Registry(name="dataset")
# The callers of the DATASETS are from the module data, we need to manually import it.
DATASETS.import_module_from_module_names(["data"])
EVALUATE = Registry(name="evaluate")
# The callers of the EVALUATE are from the module evaluate, we need to manually import it.
EVALUATE.import_module_from_module_names(["evaluate"])
```
## Thanks
- [fvcore](https://github.com/facebookresearch/fvcore)