Spaces:
Runtime error
Runtime error
File size: 2,459 Bytes
14ee1a9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# Adding new models
* You developed a new model / framework that perform very good results. Now you want to benchmark it with other models. How you can do it?
In this guide we will be adding new model to the codebase and extend the code.
## Integrating your model into VideoGenHub
To add your model codebase into VideoGenHub codebase, you must modify the following folders:
* `src/videogen_hub/infermodels` : where you create a class interface for the model inference.
* `src/videogen_hub/pipelines` : where you move your codebase into it without much tidy up work.
### How to write the infermodel class
The infermodel class is designed to have minimal methods. However, it must contain the following methods:
* `__init__(args)` for class initialization.
* `infer_one_video(args)` to produce 1 video output. Please try to set the seed as 42.
In that case, you will add a new file in `infermodels` folder.
`infermodels/awesome_model.py`
```python
import torch
from videogen_hub.pipelines.awesome_model import AwesomeModelPipeline
class AwesomeModelClass():
"""
A wrapper ...
"""
def __init__(self, device="cuda"):
"""
docstring
"""
self.pipe = AwesomeModelPipeline(device=device)
def infer_one_video(self, prompt, seed=42):
"""
docstring
"""
self.pipe.set_seed(seed)
video = self.pipe(prompt=prompt)
return video
```
Then you can add a line in `infermodels/__init__.py`:
```shell
from .awesome_model import AwesomeModelClass
```
### Writing your pipeline
About `AwesomeModelPipeline`, it means you need to write a Pipeline file that wraps the function of your codebase, such that the infermodel class can call it with ease.
We recommend structuring code in the `pipelines` folder in this way:
```shell
βββ awesome_model
βββ pipeline_awesome_model.py
βββ awesome_model_src
β βββ ...
βββ __init__.py
```
## Running experiment with new model
After finishing and reinstalling the package through
```shell
pip install -e .
```
You should be able to use the new model.
### Matching environment
Make sure the code can be run with the VideoGenHub environment. If new dependency is added, please add them to the env_cfg file.
## Submitting your model as through a PR
Finally, you can submit this new model through submiting a Pull Request! Make sure it match the code style in our contribution guide. |