There are already multiple models implement in DeepDIVA, however it is inevitable that you will want to implement your own.
To do so, it is necessary to put its definition in the right folder and annotate it with the decorator.
Just put the .py
model specification file in the models
folder.
To keep them organised, there are different folders for different types of models, but it does not matter from the execution point of view.
In order to make your model visible to the framework you need to annotate the function/class which creates your model with @Model
decorator.
For example:
import torch.nn as nn
from models.registry import Model
class MyNetwork(nn.Module):
def __init__(self, **kwargs):
...
def forward(self, x):
...
Any other function or classes in that file which are NOT annotated with the decorator will not be visible outside and thus cannot be run as models.
You can create your model from the scratch, import it from internet (e.g from PyTorch zoo) or just copy an existing model in DeepDIVA and modify it.