Update PLUGINS.md

add docs for dataloader plugin hooks
This commit is contained in:
Victor Hall 2023-12-20 15:29:33 -05:00 committed by GitHub
parent d9d2a43804
commit 83623929ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -29,3 +29,13 @@ class MyPlugin(BasePlugin):
def on_epoch_end(self, **kwargs):
print(f"hello world, this is a plugin at the end of epoch number: {kwargs['epoch']}")
```
## Data loader hooks
These runs every time the image/caption pair are loaded and passed into the training loop. These do not use kwargs, but are focused on specific parts of the data loading routine.
#### transform_caption(self, caption:str)
Could be useful for things like customized shuffling algorithms, word replacement/addition/removal, randomization of length, etc.
#### transform_pil_image(self, img:Image)
Could be useful for things like color grading, gamma adjustment, HSL modifications, etc. Note that AFTER this function runs the image is converted to numpy format and normalized (std_dev=0.5, norm=0.5), so normalization is wasted compute. From prior experimentation, all adjustments to the standard normalization are a waste of time. Gamma or curve adjustments are still potentially useful.