Download docs/finetrainers-src-codebase/finetrainers/processors/text.py from jbilcke-hf/VideoModelStudio: direct link, hf CLI and curl.
- Browser
- Download file 687 Bytes
-
https://huggingface.co/spaces/jbilcke-hf/VideoModelStudio/resolve/main/docs/finetrainers-src-codebase/finetrainers/processors/text.py
- Command line
-
hf download hf://spaces/jbilcke-hf/VideoModelStudio/docs/finetrainers-src-codebase/finetrainers/processors/text.py
-
curl -L -o text.py https://huggingface.co/spaces/jbilcke-hf/VideoModelStudio/resolve/main/docs/finetrainers-src-codebase/finetrainers/processors/text.py
687 Bytes
| from typing import List, Union | |
| import torch | |
| import finetrainers.functional as FF | |
| from .base import ProcessorMixin | |
| class CaptionTextDropoutProcessor(ProcessorMixin): | |
| def __init__(self, dropout_p: float = 0.0) -> None: | |
| self.dropout_p = dropout_p | |
| def forward(self, caption: Union[str, List[str]]) -> Union[str, List[str]]: | |
| return FF.dropout_caption(caption, self.dropout_p) | |
| class CaptionEmbeddingDropoutProcessor(ProcessorMixin): | |
| def __init__(self, dropout_p: float = 0.0) -> None: | |
| self.dropout_p = dropout_p | |
| def forward(self, embedding: torch.Tensor) -> torch.Tensor: | |
| return FF.dropout_embeddings_to_zero(embedding, self.dropout_p) | |