TL;DR
This paper introduces Black-box Adversarial Reprogramming (BAR), a novel technique that repurposes pre-trained, black-box machine learning models (like commercial APIs) for entirely new tasks without needing access to their internal weights or architecture. By combining zeroth-order optimization with adversarial input perturbations, BAR achieves state-of-the-art performance on data-scarce medical imaging tasks for just a few dollars in API query costs.
The Challenge of Black-Box Transfer Learning
Transfer learning typically requires "white-box" access to a pre-trained model to fine-tune its internal weights for a new task. However, many powerful, state-of-the-art models are locked behind proprietary APIs (e.g., Google Cloud Vision, Clarifai) where users can only input data and receive output predictions.
Furthermore, in fields like medical imaging, training data is incredibly scarce and expensive to obtain, making training from scratch or even standard fine-tuning difficult. While a technique called "Adversarial Reprogramming" (AR) previously showed that models can be repurposed simply by adding a learned visual perturbation to the input image, it still required white-box access to compute gradients via backpropagation. This paper bridges that gap, asking: Can we reprogram a completely black-box model using only its input-output responses, especially when we have very little training data?
Introducing Black-box Adversarial Reprogramming (BAR)
The authors propose Black-box Adversarial Reprogramming (BAR). The core idea is to learn a universal "adversarial program" (a visual perturbation) that is added to the target domain images (e.g., an fMRI scan). When this perturbed image is fed into the black-box model (e.g., an ImageNet classifier), the model is tricked into outputting specific source labels that the user has mapped to the new target labels.
Key techniques enabling this include:
- Zeroth-Order Optimization: Since backpropagation isn't possible without model weights, BAR estimates gradients by querying the black-box model with slightly perturbed inputs and observing the changes in the output confidence scores.
- Multi-Label Mapping (MLM): Instead of mapping one source label (e.g., "dog") to a target label (e.g., "Autism"), BAR maps multiple source labels to a single target label using a frequency-based assignment.
- Focal Loss: The authors swap standard cross-entropy loss for focal loss, which penalizes low-confidence predictions more heavily and improves convergence in this adversarial setting.
Datasets
The researchers tested BAR using several source models and target datasets:
- Source Models: Pre-trained ImageNet classifiers (ResNet50, Inception V3, DenseNet 121), plus real-world commercial APIs (Clarifai NSFW/Moderation APIs, and Microsoft Custom Vision trained on GTSRB traffic signs).
- Target Medical Datasets (Data Scarce):
- Autism Spectrum Disorder (ASD): ABIDE dataset (fMRI brain-regional correlation graphs).
- Diabetic Retinopathy (DR): Kaggle challenge dataset (retina images).
- Melanoma Detection: ISIC dataset (skin cancer images).
Key Insights and Results
- Finetuning isn't strictly necessary: You can achieve state-of-the-art transfer learning performance purely by modifying the input data, leaving the massive pre-trained model completely untouched.
- Black-box APIs are highly malleable: Commercial APIs trained for entirely unrelated tasks (like detecting NSFW content or traffic signs) can be "hacked" via BAR to diagnose Autism or Diabetic Retinopathy with high accuracy.
- Frequency-based mapping beats random mapping: Aligning the target labels with the source labels that the model naturally predicts most frequently for the target dataset (before reprogramming) provides a massive 3-5% accuracy boost over random label assignment.
- Cost-effective AI: You don't need massive compute budgets to get SOTA medical ML models. You can rent a commercial API and reprogram it for less than $30.
Performance Highlights: * On the ASD classification task, BAR achieved 70.33% accuracy using a black-box ResNet50, outperforming standard fine-tuning (52.88%) and previous SOTA methods (69.40%). * On Diabetic Retinopathy, BAR hit 79.33% accuracy, beating the fine-tuning baseline (76.63%). * On Melanoma detection, BAR reached 81.71% accuracy, significantly outperforming fine-tuning (76.90%). * Real-world API hacking: The authors successfully reprogrammed the Clarifai Moderation API to detect Diabetic Retinopathy with 72.75% accuracy. The total cost of the API queries required to estimate the gradients and train the adversarial program was only $31.68.
Limitations and Future Work
While powerful, BAR comes with specific constraints:
- Query Budget vs. Accuracy Trade-off: Zeroth-order optimization requires multiple queries per training step to estimate gradients. Higher accuracy requires more random vectors ($q$), which linearly increases the number of API queries and the associated financial cost.
- Requires Confidence Scores: The method relies on observing the continuous output probabilities (confidence scores) of the black-box model to compute the loss and estimate gradients. It would likely fail or require modification if an API only returned hard labels (e.g., returning just "Dog" instead of "Dog: 99%").
The authors plan to release their code to encourage exploring BAR on other classification tasks beyond medical imaging, potentially expanding the scope of what black-box models can be repurposed to do.
Summary updated