vision_unlearning.utils.training

Functions

tokenize_captions(examples, tokenizer, caption_column)

Adapted from The HuggingFace Inc. team. All rights reserved.

unwrap_model(model, accelerator)

Adapted from The HuggingFace Inc. team. All rights reserved.

forget_tokens(examples, tokenizer, caption_column, ...)

preprocess_train(examples, tokenizer, caption_column, ...)

Adapted from The HuggingFace Inc. team. All rights reserved.

collate_fn(examples)

Adapted from The HuggingFace Inc. team. All rights reserved.

launch_accelerated_training(unlearner)

Wrap your training function with the accelerator

Module Contents

vision_unlearning.utils.training.tokenize_captions(examples, tokenizer, caption_column, is_train=True)[source]

Adapted from The HuggingFace Inc. team. All rights reserved. Licensed under the Apache License, Version 2.0. Source: https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image_lora.py

vision_unlearning.utils.training.unwrap_model(model, accelerator)[source]

Adapted from The HuggingFace Inc. team. All rights reserved. Licensed under the Apache License, Version 2.0. Source: https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image_lora.py

vision_unlearning.utils.training.forget_tokens(examples, tokenizer, caption_column, forget_prompt: str)[source]
vision_unlearning.utils.training.preprocess_train(examples, tokenizer, caption_column, image_column, train_transforms, overwrite_column: str | None = None, concept_overwrite: str | None = None)[source]

Adapted from The HuggingFace Inc. team. All rights reserved. Licensed under the Apache License, Version 2.0. Source: https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image_lora.py

concept_overwrite: concept to be used for overwriting, described as an textual string (used to modify the prompt).

TODO: this handling of concept_overwrite is weird… I wish this were somewhat more structured/organized/clear. For example, the overwriting string may need a more complex prompt than just “an image of f{concept_overwrite}”, or with a different article

vision_unlearning.utils.training.collate_fn(examples)[source]

Adapted from The HuggingFace Inc. team. All rights reserved. Licensed under the Apache License, Version 2.0. Source: https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image_lora.py

vision_unlearning.utils.training.launch_accelerated_training(unlearner: Unlearner)[source]

Wrap your training function with the accelerator