Metadata-Version: 2.4
Name: vision-unlearning
Version: 1.0.0
Summary: Vision Unlearning: a tool for Machine Unlearning in Computer Vision
License: Apache-2.0
License-File: LICENSE
Keywords: machine unlearning,machine learning,deep learning,computer vision
Author: Leonardo Santiago Benitez Pereira
Author-email: lsbenitezpereira@gmail.com
Requires-Python: >=3.10,<3.13
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: GitPython (<3.1.19)
Requires-Dist: Jinja2
Requires-Dist: Pillow
Requires-Dist: PyYAML
Requires-Dist: Unidecode (>=1.4.0,<1.5.0)
Requires-Dist: accelerate (>=0.31.0)
Requires-Dist: autodoc_pydantic
Requires-Dist: black
Requires-Dist: build
Requires-Dist: compel (==0.1.8)
Requires-Dist: dadapy (>=0.3,<0.4)
Requires-Dist: datasets (>=2.19.1)
Requires-Dist: diffusers (>=0.30.0,<0.31.0)
Requires-Dist: filelock
Requires-Dist: flax (>=0.4.1)
Requires-Dist: hf-doc-builder (>=0.3.0)
Requires-Dist: huggingface-hub (>=0.27.0)
Requires-Dist: image-similarity-measures
Requires-Dist: importlib_metadata
Requires-Dist: invisible-watermark (>=0.2.0)
Requires-Dist: isort (>=5.5.4)
Requires-Dist: jax (>=0.4.1)
Requires-Dist: jaxlib (>=0.4.1)
Requires-Dist: k-diffusion (>=0.0.12)
Requires-Dist: librosa
Requires-Dist: lpips
Requires-Dist: matplotlib (>=3.10.0,<4.0.0)
Requires-Dist: mypy (>=1.12,<1.13)
Requires-Dist: myst-parser (>=4.0,<4.1)
Requires-Dist: networkx (>=3.0)
Requires-Dist: note_seq
Requires-Dist: numpy
Requires-Dist: onnx
Requires-Dist: opencv-python
Requires-Dist: parameterized
Requires-Dist: peft (>=0.17.0,<0.18.0)
Requires-Dist: phonemizer
Requires-Dist: piq (>=0.8.0,<0.9.0)
Requires-Dist: protobuf (>=3.20.3,<4)
Requires-Dist: pycodestyle (>=2.12,<2.13)
Requires-Dist: pydantic
Requires-Dist: pyfftw
Requires-Dist: pytest
Requires-Dist: pytest-asyncio (>=0.24.0,<0.25.0)
Requires-Dist: pytest-timeout
Requires-Dist: pytest-xdist
Requires-Dist: regex (!=2019.12.17)
Requires-Dist: requests
Requires-Dist: requests-mock (==1.10.0)
Requires-Dist: ruff (==0.1.5)
Requires-Dist: safetensors (>=0.3.1)
Requires-Dist: scikit-learn
Requires-Dist: scipy
Requires-Dist: seaborn
Requires-Dist: sentencepiece (>=0.1.91,!=0.1.92)
Requires-Dist: setuptools (>61.0.0)
Requires-Dist: shap (>=0.49.1,<0.50.0)
Requires-Dist: sphinx (>=7.4,<7.5)
Requires-Dist: sphinx-autoapi (>=3.6,<3.7)
Requires-Dist: sphinx-rtd-theme (>=2.0,<2.1)
Requires-Dist: tensorboard
Requires-Dist: tiktoken (>=0.7.0)
Requires-Dist: torch (>=2.8.0,<2.9.0)
Requires-Dist: torchmetrics
Requires-Dist: torchsde
Requires-Dist: torchvision
Requires-Dist: transformers (>=4.55.0,<4.56.0)
Requires-Dist: twine
Requires-Dist: urllib3 (<=2.0.0)
Requires-Dist: wheel
Project-URL: Documentation, https://vision-unlearning.readthedocs.io/
Project-URL: Repository, https://github.com/LeonardoSanBenitez/vision-unlearning
Description-Content-Type: text/markdown

# Vision Unlearning

<!-- ![CI](https://github.com/LeonardoSanBenitez/vision-unlearning/actions/workflows/tests.yml/badge.svg) -->

<!-- Seperate batches for 3 tests-->
![Mypy](https://github.com/LeonardoSanBenitez/vision-unlearning/actions/workflows/mypy.yml/badge.svg?branch=dev&job=mypy)
![Pycodestyle](https://github.com/LeonardoSanBenitez/vision-unlearning/actions/workflows/pycodestyle.yml/badge.svg?branch=dev&job=pycodestyle)
![Pytest](https://github.com/LeonardoSanBenitez/vision-unlearning/actions/workflows/pytest.yml/badge.svg?branch=dev&job=pytest)
![Coverage](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/LeonardoSanBenitez/vision-unlearning/dev/coverage.json)
[![Publish Package to PyPI](https://github.com/LeonardoSanBenitez/vision-unlearning/actions/workflows/publish.yml/badge.svg)](https://github.com/LeonardoSanBenitez/vision-unlearning/actions/workflows/publish.yml)


[Documentation](https://vision-unlearning.readthedocs.io/)

## Installation

```sh
pip install vision-unlearning
```

Compatible with python 3.10 to 3.12.

## What is Vision Unlearning?

Vision Unlearning provides a standard interface for unlearning algorithms, datasets, metrics, and evaluation methodologies commonly used in Machine Unlearning for vision-related tasks, such as image classification and image generation.

It bridges the gap between research/theory and engineering/practice, making it easier to apply machine unlearning techniques effectively.

Vision Unlearning is designed to be:
- Easy to use
- Easy to extend
- Architecture-agnostic
- Application-agnostic

## Who is it for?

### Researchers
For Machine Unlearning researchers, Vision Unlearning helps with:
- Using the same data splits as other works, including the correct segmentation of forget-retain data and generating data with the same prompts.
- Choosing the appropriate metrics for each task.
- Configuring evaluation setups in a standardized manner.

### Practitioners
For practitioners, Vision Unlearning provides:
- Easy access to state-of-the-art unlearning algorithms.
- A standardized interface to experiment with different algorithms.

# Tutorials

* [Replace _George W. Bush_ by _Tony Blair_ using FADE](https://colab.research.google.com/drive/1ZJG9By4_u1Vqy_SYelxfzUUImRzayRYw?usp=sharing)
* [Replace _George W. Bush_ by _Tony Blair_ using FADE sparse-per-module](https://colab.research.google.com/drive/1luM3kAoaBLoTwcsDcW3KO_SIiuIbwmWY?usp=sharing)
* [Replace _George W. Bush_ by _Tony Blair_ using FADE sparse-per-weigth](https://colab.research.google.com/drive/1ry5xXOPMuVm_LA_4Uyk27Aqe52L607kO?usp=sharing)
* [Forget _cat_ using UCE (with hyperparam tunning)](https://drive.google.com/file/d/1OZtNkntOj-dVpo-T1kQdPMK7TMYX3ctf/view?usp=sharing)
* [Forget _church_ using Munba](https://colab.research.google.com/drive/1eyjrNMcYi0PK37U0ZLcwydy153yiJUJ9?usp=sharing)

The source code for these tutorials is in `tutorials/`, but their outputs were cleaned to avoid burdening the repo.
The links above contain Google Drive stored executions with the full outputs.

> For developers: every time there is a relevant modification in the codebase, please run the affected tutorials, save the notebook to Drive, clear the output before commiting.


# Benchmarks

Vision-Unlearning provides easy access to evaluation benchmarks.

Across all benchmarks, a standardized set of files/media/metadata/content is provided following the structure described in the Appendix 2 of I-CARE paper. As such, they are compatible with [Forgety](https://github.com/LeonardoSanBenitez/forgety). 


## I-CARE

Even though the feasibility demonstration of the I-CARE methodology is not per se a full-fledged benchmark, it is exposed by Vision-Unlearning as one. Three independent tasks are analyzed (forgetting people, scenes, and dog breeds) across three unlearning methods  from the state-of-the-art (UCE, SPARE, MUNBa). Data, models, metrics and computed results are provided its [HuggingFace repository](huggingface.co/datasets/LeonardoBenitez/VisionUnlearningEvaluationTestbeds). See code details in `vision_unlearning/benchmarks/I_care`.


This work analyzes how unlearning one entity (the emitter) affects the performance on other closely-related entities (the receivers). Each task is defined by carefully selecting a diverse and representative set of entities (concepts that will undergo unlearning). Each entity is annotated with relevant attributes, and separately unlearned using different unlearning methods. Each unlearned model is then used to generate images for all entities, allowing fine-grained analysis of the effects caused by the unlearning process. Last but not least, all entities contain the same amount of images and were carefully selected so as to be balanced across at least 2 attributes.


## Unlearn Canvas
TODO... still under construction...

For more information on the benchmark itself, please refer to their repository https://github.com/OPTML-Group/UnlearnCanvas.


Data, models, metrics and computed results used by Vision-Unlearning are [or will be] provided [this HuggingFace repository](https://huggingface.co/datasets/LeonardoBenitez/u-care).
See code details in `vision_unlearning/benchmarks/u_care`.

## Holistic Unlearning Benchmark (HUB)
TODO... still under construction...

For more information on the benchmark itself, please refer to their paper: https://arxiv.org/abs/2410.05664

Data, models, metrics and computed results used by Vision-Unlearning are [or will be] provided [this HuggingFace repository](https://huggingface.co/datasets/LeonardoBenitez/hub-care).
See code details in `vision_unlearning/benchmarks/hub_care`.

# Forgety
[Forgety](https://github.com/LeonardoSanBenitez/forgety) is a related project built on top of this library, providing a web-based graphical UI.



# Main Interfaces

Vision Unlearning standardizes the following components:

- **Metric**: Evaluates a model (e.g., FID, CLIP Score, MIA, NudeNet, etc.).
- **Unlearner**: Encapsulates the unlearning algorithm.
- **Dataset**: Encapsulates the dataset, including data splitting.

Additionally, common tasks and evaluation setups are provided as example notebooks. Several platform integrations, such as Hugging Face and Weights & Biases, are also included.

![uml](docs/images/UML.png)

# Citation

We don't have yet a paper specifically about the library. Instead, please cite the Zenodo DOI that releases the data for the testbeds:

```
@dataset{vision_unlearning_evaluation_testbeds,
  author       = {Benitez Pereira, Leonardo Santiago and
                  Mola, Natnael and
                  R. Kelsch, Carolina and
                  Vaze, Soham},
  title        = {Vision Unlearning Evaluation Testbeds},
  month        = feb,
  year         = 2026,
  publisher    = {Zenodo},
  version      = {0.1.0},
  doi          = {10.5281/zenodo.18649818},
  url          = {https://doi.org/10.5281/zenodo.18649818},
}
```




