NATAILI\
├───aitemplate
├───blip
├───cache
├───clip
│ └───predictor
├───codeformers
├───esrgan
├───gfpgan
├───model_manager
├───sdu
├───stable_diffusion
│ └───diffusers
├───train
│ ├───dataset
│ │ └───EveryDream
│ ├───dreambooth
│ └───lora
└───util
├───blip
├───codeformer
└───gfpgan
aitemplateblipclippredictor
codeformersesrgangfpganstable_diffusiondiffusers
traindatasetEveryDream
dreamboothlora
Generally speaking, each model type has a folder with the same name and related files in that folder.
Sometimes, a model type has a subfolder for a subtype of the model type. For example, the clip model type.
NATAILI\CLIP
├───coca.py # LAION-CoCa
├───image.py # Image embedding
├───interrogate.py # Interrogation / similarity
├───text.py # Text embedding
└───predictor
├───inference.py # Predictor inference
├───mlp.py # MLP for predictor
├───prepare.py # Preparing dataset for predictor training
└───train.py # Predictor training
-
LAION-CoCa is a model that uses CLIP, so it is in the
clipfolder. -
CLIP Image and text embedding functions are in the
image.pyandtext.pyfiles, respectively. -
The
interrogate.pyfile contains the interrogation and similarity functions. -
The
predictorfolder contains several modules that are used for the CLIP+MLP predictor. These are grouped together in a folder because they are all related to the predictor.
Other examples of this are the diffusers folder in the stable_diffusion model type, and the train folder.
- Nataili mainly supports CompVis so
stable_diffusioncontainscompvis.py - Depth2img and Inpainting models are implemented via diffusers pipelines, so they are in the
diffusersfolder.depth2img.pyandinpainting.pyrespectively.
NATAILI\TRAIN
├───dataset
│ └───EveryDream
├───dreambooth
│ └───dreambooth_lora.py
└───lora
└───lora.py
-
datasetcontains additional dataloaders that can be used for training. -
dreamboothcontains the Dreambooth training scripts, e.g.dreambooth_lora.py- this is Dreambooth with LoRA (and EveryDream). Others can be implemented here e.g.dreambooth_diffusers.py- this could be a version resembling the diffusers example script. Or a version with a different dataset e.g.dreambooth_lorawithout EveryDream. -
lorais everything related to LoRA. -
trainwould be expanded with other types of training e.g.train\textual_inversionfor textual inversion training ortrain\pivotal_tuningfor pivotal tuning training. LoRA versions of these would be under their respective folders and named accordingly e.g.textual_inversion_lora.pyorpivotal_tuning_lora.py.
NATAILI\MODEL_MANAGER
├───aitemplate.py
├───base.py
├───blip.py
├───clip.py
├───codeformer.py
├───compvis.py
├───diffusers.py
├───esrgan.py
├───gfpgan.py
├───new.py
├───safety_checker.py
├───sdu.py
└───super.py
- Each model type has a corresponding file in the
model_managerfolder. These files contain the model manager class for that model type. base.pycontains the base model manager class. This is the parent class for all model manager classes. It contains the basic functions that all model managers can use.new.pyis a template for creating a new model manager class. It contains the basic structure of a model manager class.- Copy this file and rename it to the name of the model type you want to create a model manager class for.
- ctrl+f
newand replace each instance with the name of the model type. - Now you can modify the
loadandload_modelfunctions for the model type. - General structure of
loadandload_modelshould remain the sameloadchecks if the model is valid, if it is available, and downloads the model if it is not available.#loadcallsload_modelwhich loads the model and returns it.load_modelwill override device/precision as needed i.e. CUDA unavailable, or precision is not supported.- The model is then stored in the Model Manager class instance under
self.loaded_model[model_name].
super.pycontains the super model manager class. This was created for backwards compatibility with v0.0.1/Stable Horde worker, as such it has a different structure to the other model manager classes, and does not have all the functions that the other model manager classes have.- A model manager class can handle subtypes of a model type.
clipmodel manager class handles models with type"clip","open_clip"and"coca", these are loaded in different ways so they are handled by different functions.- This type is defined in the model's database .json file.
"type": "clip"for example.