An official implementation of the paper Anti-adversarial fingerprints enable persistent copyright protection of healthcare data.
The paper is still underreview! The open-access version of the paper can be downloaded from Arxiv. Feel free to clone our full project, test, and even make improvements on your own.
The growing adoption of data-driven healthcare AI raises a key question: how can we protect sensitive medical data without hindering its use? Existing methods like encryption and watermarking only act before data distribution and cannot control models trained on protected data. We introduce DataCook, a deployment-phase framework that embeds imperceptible anti-adversarial fingerprints into medical data. These fingerprints enhance model confidence for authorized inputs while degrading performance for unauthorized ones, ensuring persistent and fine-grained copyright protection. DataCook supports 2D/3D and high-resolution medical imaging as well as non-image modalities, enabling secure sharing without sacrificing model utility.
- Environment Setup
- Dataset Preparation
- How to Run Our Codes)
- Transfer Testing
- High-Resolution & 3D
- Baselines
- Command-Line Arguments
- Citation
- Contact
# Create conda environment
conda create -n datacook python=3.8 -y
conda activate datacook
# Install required dependencies
pip install -r requirements.txtWe primarily use datasets from MedMNIST. Please download them via the official Python API or manually place them under:
./data/MedMNIST/Example:
from medmnist import BloodMNIST
from torchvision import transforms
transform = transforms.Compose([transforms.ToTensor()])
train_dataset = BloodMNIST(split='train', transform=transform, download=True, root='./data/MedMNIST')
test_dataset = BloodMNIST(split='test', transform=transform, download=True, root='./data/MedMNIST')We also support tabular datasets. Please place them under:
./data/TableData/| Dataset Name | Download Link |
|---|---|
| Pima Indians Diabetes dataset | Using the ADAP Learning Algorithm to Forecast the Onset of Diabetes Mellitus |
| Hepatitis C Prediction dataset | UCI Machine Learning Repository |
| Systemic Diseases dataset | UK biobank |
Example: Run DataCook on BloodMNIST (2D)
# Step 1: Search perturbation noise
cd scripts/Datacook/2d/BloodMNIST
./search_perturbation_noise.sh
# Step 2: Train model with generated perturbations
cd scripts/Datacook/2d/BloodMNIST
./train.shYou can follow the same format to add other datasets.
Example: Run tabular datasets - systemic diseases.csv.
# Step 1: pretrain model
cd TableData
python MLP.py
# Step 2: Generated perturbations and get result such as using datcook
python PrivacyAttacker.py --attack_type datacookTo test transferability on another model (e.g., from ResNet-18 to ResNet-50),
modify the model_name argument in train.sh:
model_name=resnet50For high-resolution and 3D datasets, see:
scripts/Datacook/high-resolution/
scripts/Datacook/3d/We provide the following baselines in scripts/:
- Error-Minimum - EM And modified verison of EM in our paper, called EM-Pseudo
- Adversarial Poison - ADV
- Unlearnable Clusters - UC
- Synthetic Perturbations - LSP
All major hyperparameters can be set via command-line arguments in the provided .sh scripts.
Please refer to each train.sh or search_perturbation_noise.sh file for details.
If you use this code, please cite the following:
We adapted some codes from:
For any questions or collaborations, please contact: Max Shang – loveligo97@gmail.com
