Metadata-Version: 2.4
Name: scramblekit
Version: 0.1.0
Summary: Image scrambling for privacy-preserving deep learning: block-wise scrambling (LE/ELE/EtC/PE), adaptation networks, scrambling parameter generation, SIA-GAN and ScrambleMix
Author: Koki Madono
License-Expression: MIT
Project-URL: Homepage, https://github.com/MADONOKOUKI/scramblekit
Project-URL: Documentation, https://github.com/MADONOKOUKI/scramblekit/tree/main/docs
Project-URL: Repository, https://github.com/MADONOKOUKI/scramblekit
Project-URL: Issues, https://github.com/MADONOKOUKI/scramblekit/issues
Project-URL: Paper (block-wise scrambling), https://arxiv.org/abs/2001.07761
Project-URL: Paper (SPG), https://doi.org/10.2352/ISSN.2470-1173.2021.11.HVEI-155
Project-URL: Paper (SIA-GAN), https://doi.org/10.1109/ACCESS.2021.3112684
Project-URL: Paper (ScrambleMix), https://doi.org/10.1007/978-981-97-0376-0_25
Keywords: image scrambling,privacy-preserving machine learning,learnable image encryption,EtC,adaptation network,LPIPS,GAN attack,data augmentation,PyTorch
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Image Processing
Classifier: Topic :: Security
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: pillow
Provides-Extra: torch
Requires-Dist: torch>=1.13; extra == "torch"
Requires-Dist: torchvision; extra == "torch"
Provides-Extra: lpips
Requires-Dist: torch>=1.13; extra == "lpips"
Requires-Dist: torchvision; extra == "lpips"
Requires-Dist: lpips; extra == "lpips"
Provides-Extra: all
Requires-Dist: torch>=1.13; extra == "all"
Requires-Dist: torchvision; extra == "all"
Requires-Dist: lpips; extra == "all"
Dynamic: license-file

# scramblekit

Image scrambling for privacy-preserving deep learning: the block-wise scrambling schemes LE, ELE, EtC and
pixel-based encryption, the adaptation networks that classify scrambled images, scrambling parameter generation,
the SIA-GAN inversion attack and ScrambleMix — the official library of four papers by Koki Madono et al., with the
keys and conventions of the original research code (checked bit for bit against it).

![scramblekit demo](https://raw.githubusercontent.com/MADONOKOUKI/scramblekit/main/assets/demo.png)

```bash
pip install scramblekit            # scrambling, PSNR/SSIM, SPG with SSIM - NumPy + Pillow only
pip install "scramblekit[all]"     # + PyTorch/torchvision (networks, SIA-GAN, ScrambleMix) + LPIPS
scramblekit demo --out demo/       # scramble a bundled sample image with every scheme (CPU, ~1 s, no downloads)
```

```python
import numpy as np
import scramblekit
from scramblekit.scramble import ELE

img = scramblekit.sample_image()                    # 128x128 RGB uint8 (public-domain photo)
ele = ELE(key=0, image_size=128)                    # extended learnable encryption, 4x4 blocks, seed 0
scrambled = ele(img)                                # also PIL images and (N, 3, H, W) torch tensors
assert np.array_equal(ele.inverse(scrambled), img)

from scramblekit.models import build_model          # needs scramblekit[torch]
net = build_model("shakepyramidnet", num_classes=10, adaptation="ele")  # ELE-AdaptNet + ShakeDrop PyramidNet-110
```

| Paper | Module |
|---|---|
| Block-wise Scrambled Image Recognition Using Adaptation Network (AAAI-20 WS AIoT) — [arXiv:2001.07761](https://arxiv.org/abs/2001.07761), [project](https://madonokouki.github.io/projects/blockscramble/) | `scramblekit.scramble` (LE, ELE, EtC, PE, block shuffling), `scramblekit.models` (LE-/ELE-AdaptNet, ShakeDrop PyramidNet) |
| Scrambling Parameter Generation to Improve Perceptual Information Hiding (Electronic Imaging 2021) — [DOI](https://doi.org/10.2352/ISSN.2470-1173.2021.11.HVEI-155), [project](https://madonokouki.github.io/projects/spg/) | `scramblekit.spg`, `scramblekit.metrics` (LPIPS, PSNR, SSIM) |
| SIA-GAN: Scrambling Inversion Attack Using Generative Adversarial Network (IEEE Access 2021) — [DOI](https://doi.org/10.1109/ACCESS.2021.3112684), [project](https://madonokouki.github.io/projects/siagan/) | `scramblekit.attack` |
| ScrambleMix: A Privacy-Preserving Image Processing for Edge-Cloud Machine Learning (PSIVT 2023) — [DOI](https://doi.org/10.1007/978-981-97-0376-0_25), [project](https://madonokouki.github.io/projects/scramblemix/) | `scramblekit.augment` |

Command line: `scramblekit demo | train | spg | attack | cite` (`--dataset fake` for smoke runs without
downloads). Documentation, the Colab notebook, the list of paper-vs-code differences and the links to the paper
repositories: https://github.com/MADONOKOUKI/scramblekit

If scramblekit helps your research, please cite the paper(s) of the modules you use: `scramblekit cite` (or
`scramblekit.cite(name)`) prints the BibTeX entries.
