Paper: Not Just Pretty Pictures: Toward Interventional Data Augmentation Using Text-to-Image Generators (ICLR-2024)

Reviewer comment (Evaluation):
In figure 3, it seems that Text2Image variant has the least biases across all three datasets. But the text on page 8 the authors suggest that "Text2Image seems to be less effective than other techniques in reducing background and texture biases". Can the authors clarify this?

Author response:
**Q1: Figure 3 shows Text2Image is the best at RRSF, but statements on page 8 seem to contradict this.**


We thank the reviewer for pointing out the typo. We fixed it in the revised draft (in red). Text2Image is indeed the most effective approach.

Reviewer comment (Novelty):
The results in Figure 2 where the Text2Image variant performs better/comparable to SDEdit variant undermine the idea proposed in the paper. In the Text2Image variant, there is no image conditioning for generating images. Several other papers [1] have also shown that using synthetic data from generative models improves the generalization performance of the classifiers. Where is the novelty then coming for this paper?

Author response:
**Q2.1: The effectiveness of Text2Image “undermine[s] the idea proposed in the paper”**


Please refer to **General Response (B)**.


**Q2.2: “Where is the novelty” relative to [1]?**


The goal of [1] is to show: 
*  it is possible to fine-tune stable diffusion to produce a class-conditional generative model whose synthetic samples mimic the training distribution (goal: reduce gap between synthetic and real)
* they test the performance on i.i.d samples with respect to the training set

Our goal is to:
* provide an extensive analysis of how to best use zero-shot generative techniques to simulate non-i.i.d. test domains (with no form of fine-tuning!)
* we test the performance on non-i.i.d. test domains, showing zero-shot generated samples can be used to reduce bias and improve generalisation across a wide variety of domains
* draw conclusions about how to most effectively exploit zero-shot generative capabilities of SD
Thus, while [1] is an interesting related work (which is why we cite it in both Sections 1 and 2), the authors’ purpose, experimental setting, and results are all distinct from ours. For additional context, please consult our list of contributions in **General Response (C).**


**P1**: **the fact that the "Text2Image" baseline performs better/comparable to SDEdit variant undermines the novelty of the paper**

We respectfully disagree, because our novelty is *not* to establish SDEdit as the best performing method, it is to study a range of image synthesis and editing techniques (including both SDEdit and Text2Image) in the context of SDG and RRSF. We make a more detailed argument on this point in **General Response (B)** (Conditioning and Interventions); but in sum: it is a contribution, not a contradiction, that our investigation explores both ways to simulate interventions and finds Text2Image to often outperform SDEdit.

**P2.1: [with respect to] [1], I feel the main idea is still the same**

The main similarity between [1] and our work is the use of foundational generative models to generate synthetic data to train classifiers. (We do not claim novelty on this point, and in Section 2, we provide a detailed discussion of additional works that are also similar to our work in this respect.) Below, we note several key differences between our work and [1]. 

In [1], the authors show:
- Assuming **access to all images of ImageNet**, Imagen can produce the best **approximation of ImageNet if fine-tuned** on it (according to FID, IS and CAS scores)
- Adding the so-produced approximation of ImageNet to the ImageNet training set improves classification performance **on ImageNet itself**. 
- Although the authors talk of performing augmentations in the abstract, the generated data is explicitly generated to resemble ImageNet. **No deliberate manipulation of the image features is performed. The test set is i.i.d. with respect to the dataset**.

In our work: 
- Assuming **no access to non-i.i.d. test domains training data**, Stable Diffusion can approximate them **zero-shot** if some **meta-data** is accessible. No image is accessed from the non-i.i.d. test domains. This is a significantly more difficult problem that **cannot be solved with more available i.i.d. training data (like [1] does)**. If, similarly to [1], we assumed full access to the test domain (non-i.i.d., in our case), the problem would not even require a generative model to be solved with perfect accuracy on PACS/Office-Home. 
- Adding the zero-shot generated non-i.i.d. data to i.i.d. data, we improve the performance **on non-i.i.d. test data** (not accessible for any form of fine-tuning) and reduce the impact of **biases** on model's predictions.
- Our experiments in the main paper and rebuttal (Table 2 in the paper,  Q2 response to reviewer MWyF) show **exact knowledge of the meta-data is not required**. 
- We ablate and analyse which conditioning, prompting and filtering techniques produce the best performance, and compare with a retrieval baseline pointing out weaknesses and strengths of all approaches in different settings, as already extensively discussed in **General Response (C)** (Novelty and Contribution).

**P2.2: the experimental setting and results are different to [1], I feel the main idea is still the same"** 

The different experimental setting is not a minor difference. The availability of i.i.d. training data and testing only on i.i.d. training data vs. the non-availability of non-i.i.d. data and testing on non-i.i.d. test data is the fundamental difference that distinguishes in-domain generalization (which [1] addresses) and out-of-domain generalization and reducing the reliance on spurious features (which we address). The two fields are fundamentally different areas of research: solutions and conclusions that hold in one do not necessarily generalize to the others. Indeed, *under the assumptions of our setting, [1] would not be applicable (as there would be no non-i.i.d. data to fine-tune on).*

Having carefully read [1], it is unclear why the novelty of the results of our work are diminished by paper [1], as they operate in very different settings with different methodologies, goals, and contributions.

Reviewer comment (Experiments):
To further show that the generalization improves for unseen target domains, can the authors also show results for Cifar10-C and ImageNet-C datasets?

Author response:
**Q3: “To further show that the generalization improves for unseen target domains, can the authors also show results for Cifar10-C and ImageNet-C datasets?”**


We would like to point out that CIFAR-10-C and ImageNet-C are synthetic datasets obtained by applying some well-known parametric and handcrafted transformations to the images. Several of these transformations try to approximate the observation of different weather conditions or lighting conditions. We have experimented on 7 benchmarks, among which we have  two large scale dataset (NICO++ and DomainNet), which represent some of these transformations and are made of naturalistic data – real photos captured in, e.g., dim light, autumn weather, etc. 


However, as requested, we have also performed a comparable SDEdit experiment (using handcrafted prompts) on CIFAR-10-C:


**Cifar-10-C Result with ResNet-18**
| | Blurring Avg. | Noise Avg. | Compression Avg. | Transformations Avg. | Overall Avg. |
|-----------|---------------|------------|------------------|---------------------|--------------|
| ERM       | 72.04        | 74.01    | 75.71            | 73.93              | 73.55       |
| MixUp  | 73.79 | 76.22 | 77.46 | 75.72 | 75.48 |
| PixMix | 75.84 | 79.41 | 81.39 | 79.32 | 78.63 |
| SDEdit      | 74.28        | 75.71    | 77.10            | 75.02              | 75.11       |


It is important to note that Stable Diffusion (SD) is trained on web-scraped data, and as such we do not expect it to perform these kinds of artificial transformations as well as the naturalistic ones found in, e.g., NICO++. All the same, it appears that SD is still able to synthesize augmented data that can improve performance even on these unseen transformations. However, we note that, as these parametric transformations are artificially produced and mathematically well-understood (with implementations available in open-source libraries), it is obviously more efficient to target them with parametric augmentations at training time than with SD.

Reviewer comment (Experiments):
Almost all the results seem to assume that the target domain can be easily described and that the number of domains are known. However, this does not always hold. For example, in iwildcam, where the target domain consists of images from different camera traps resulting in different locations, viewpoints, etc., it may not be obvious how to describe the target domain.

Author response:
**Q1.1a: Assumption that “the target domains can be easily described.”**


We agree that, in principle, not all domain shifts can be easily described via language; however our work clearly targets those that can. These represent a wide variety of problems of interest (we use 7 of the most popular benchmarks in the domain-shift literature). Indeed, reference [1] suggested by the reviewer provides further evidence that even when they are not easily describable, language-driven generation can achieve impressive performance on 3 additional benchmarks. In contrast, none of the non-textual baselines are able to outperform ERM on more than a small subset of the 7 benchmarks considered by our work, clearly indicating they are less general.


**Q1.1b: Assumption that “the number of domains [is] known.”**


While it is true that our primary SGD experiments assume that the number of domains is known, we have several key experiments (experiments in Table 2, the additional NICO++ we include in response to Q2 for SGD, and all RRSF experiments) that do not.

Reviewer comment (Experiments):
The proposed method on “Breaking spurious correlations” (Fig 3) requires a human to hand craft prompts which may be expensive to attain.

Author response:
**Q1.2: Human handcrafted prompts required? Expensive to attain?**


For SDG, we experiment extensively with two prompting strategies that do not require human input: language enhancement (LE) and minimal (M). The same is very likely possible for RRSF, but for this task, we elected to focus on ablating the conditioning mechanism instead of the prompting strategy, as our results from SDG showed this to be more important. Regarding expense, we note that the handcrafted prompts took only a single participant 2-5 minutes per benchmark.  (across all 3 RRSF benchmarks).

Reviewer comment (Novelty):
For example, [1] uses a captioning model to describe the data, then gpt to summarize into domain descriptions. These descriptions are then used in the prompts. Thus, it doesn’t require knowledge of the domains.

Author response:
**Q1.3: [1] does not “require knowledge of the domains.”**


We thank the reviewer for mentioning [1]. However, we kindly note that : [1] assumes access to images of several domains to create the captions. Indeed, this is much more information than we access for, e.g., Minimal (M) prompts, which are produced with meta-data only. However, this requires explicit access to the target domain images, which is unavailable in our domain generalization setting. We will discuss the work in the revised draft. 


[1] Diversify Your Vision Datasets with Automatic Diffusion-based Augmentation. NeurIPS’23

Reviewer comment (Evaluation):
It is not clear what the message of Table 2 (“Describing the Target Domain Is Not Necessary”) is. As it is without target domain information, it seems to say that SD is biased towards generating certain domains and those domains happen to be aligned with the target for this dataset, but this may not be the case for other datasets.

Author response:
**Q2: Table 2 seems to say that SD is biased to generate some domains that happen to be aligned with the target for this dataset, but may not be the case for other datasets.**


We perform the experiment of Table 2 for NICO++, which has domains that are significantly not aligned (see the column names in the Table below). This clearly indicates the intervention performed aids generalization per-se as the improvement is substantially maintained when the target domain is not included.


**SDG NICO++ Result with ResNet-50 for comparing the effect of accessing synthetic target domain or not**


|              | autumn | dim    | grass  | outdoor| rock   | water  | Average |
|--------------|--------|--------|--------|--------|--------|--------|---------|
| ERM          | 66.74  | 70.37  | 72.05  | 71.3   | 66.58  | 72.64  | 69.95   |
| SDEdit(M) ×  | 67.90  | 71.70  | 72.61  | 72.32  | 67.10  | 73.79  | 70.90   |
| SDEdit(M) ✓  | 68.28  | 71.42  | 72.68  | 72.31  | 67.95  | 74.07  | 71.12   |

Reviewer comment (Experiments):
From A.1, it seems like there was a different number of additional data for generated images and baseline augmentation techniques. Can the authors explain this choice? It may be interesting to see how the performance changes with the amount of data, similar to (He et al., 2023; Sariyildiz et al., 2023).

Author response:
**Q3.1: Why “different number of additional data for generated images and baseline[s]”?**


The difference is caused by the current cost of generating samples with Stable Diffusion (SD). Since the process is expensive, we perform it offline before training:
* the augmentation baselines produce $D*E$ augmentations where $E= 50$ (the number of epochs), and $D$ is the size of the training set.
* the SD-based approaches generate $D*(C-1)$ samples, where $C$ is the number of domains. $C=4$ or $C=6$ across the SDG experiments.
* Since $(C-1)$ is much lower than 50, SD produces much less augmentations
The superior performance of using fewer SD-based augmentations indicates interventions targeting the right environmental variables are significantly more effective than generic   augmentations whose contribution to generalization is unclear. 


**Q3.2: How much does performance change with amounts of data similar to cited works?**


In **Appendix I.3** we already report this result for PACS. The conclusion is that a few additional data samples can help, but too much data can degrade the performance. The fact that few additional samples are enough to outperform all SOTA baselines indicates the slow generation is counterbalanced by the effectiveness of using just a few generated samples.

Reviewer comment (Novelty):
The conclusions of the paper seem similar to that of (Bansal & Grover, 2023) who also used pre-defined text prompts to generate data. They also showed that a combination of real and generated data results in better performance, although on IN-Sketch and IN-R. The evaluation setup may be slightly different but the conclusions from SDG seem to be similar.

Author response:
**Q4: Evaluation setup different but similar conclusions to Bansal & Grover (2023)?**

Bensal and Grover (2023) do not try to produce deliberate manipulations of the environmental variables, as we do. They only apply CLIP prompts to generate the data, which, only as a side-effect, results to be robust to some forms of distribution shift. 
Their contributions do not overlap with any of our contributions listed in **General Response (C).**

Reviewer comment (Evaluation):
What is the performance of Retrieval on DomainNet in Fig 5?

Author response:
**Q6: What is the performance of Retrieval on DomainNet in Fig 5?**


Thank you for drawing attention to this issue: the lack of Retrieval in DomainNet was a plotting mistake, which we have corrected in the updated draft.

Reviewer comment (Presentation):
I would suggest moving some technical details, e.g., the setup, how many images are generated for each original image, a brief description of how retrieval is done, to the main paper.

Author response:
**Q7: “[S]uggest moving some technical details, e.g. the setup, how many images are generated for each original image, a brief description of how is retrieval done, to the main paper.”**


 Thank you for your suggestion. We agree and plan to update the manuscript accordingly in the camera-ready draft.

Reviewer comment (Evaluation):
It may be useful to have an additional column in the table of results for the runtimes. The baseline augmentations should be much cheaper to attain than generating data with SD.

Author response:
**Q8: It may be useful to have an additional column in the table of results for the runtimes. The baseline augmentations should be much cheaper to attain than generating data with SD.**


We report the runtime for generation in **Appendix G**. As we already discussed the generation time is a downside, hence we perform it offline once and can be reused across models and experiments. If performed offline, loading the generated from disk is significantly faster than competing methods. We also observe:
* Reducing SD generation time is an active area of research. For instance, passing from version 1.4 and upgrading to PyTorch 2.0 and version 1.5 of stable diffusion, with adequate batching, we have already observed a 150% reduction in generation time. Making the process more efficient is out of the scope of this paper. Furthermore, the offline generative process can be easily parallelised. 
* Given the flexibility and effectiveness of the procedure, paying the price for generation can be deemed convenient if compute is available and before better and faster techniques are proposed.

Reviewer comment (Evaluation):
The paper started with the premise that IDA is known to be useful for SDG and RRSF, and proceeded with a two-fold objective of evaluating T2I generators and establishing a new state-of-art on SDG and RRSF. However, as observed from Fig. 3 and 5, text2Image and retrieval baselines performed the best, which are both non-interventional augmentations. This raises the question: What then is the role of IDA and conditional generators?

Author response:
Dear Reviewer bsQg,

We sincerely thank you for raising your rating. Thank you for recognizing our **contribution in evaluating T2I models for SDG and RRSF and experiments and acknowledging the experiments are sound**. We have indeed experimented with large-scale and challenging datasets with a wide variety of classes like NICO++ (61K imgs, 60 classes) and DomainNet (410K imgs, 345 classes; one of the most challenging benchmarks in the domain due to its outstanding **complexity and scale**) to an extent that is rarely seen in RRSF and SDG literature. 

Regarding the **tension between the following two statements**:
1. “A general IDA mechanism […] has often been conjectured as a theoretical solution” (in the abstract)
2. “Text2Image (conditioning only on text) and Retrieval generally outperform SDEdit […] indicating that augmenting the original image is not necessary.” (in our General Response)

Specifically, the tension is this: our empirical findings contrast with earlier theoretical literature, in that we generally find that “augmenting the original image is not necessary.” In other words, when we empirically test the strength of the conjectured theoretical solution (e.g., an approach like SDEdit), we find that there are alternatives (e.g., an approach like Text2Image) that perform even better without direct augmentation (i.e., not requiring sample-level alignment, per **General Response (B)**). This is a key contribution of our work: it unearths an empirical limitation of the theoretical literature, pointing to the need for additional theoretical analysis in the context of IDA.

**We will make this key point of tension and the associated empirical contribution clearer in our abstract and introduction.** We will also strive for greater clarity on the remaining points you raised and will remove ambiguous statements. 

About the **limitations of prompting**, we had already included a failure case in Appendix (on 2 datasets from the WILDS dataset mentioned by the reviewer, please refer to Figure 14) but rest assured we will emphasise this aspect more in the main paper.  

Thank you again for your careful analysis of our response, we hope these lines **address the remaining concerns** about the framing of our work. Given the little time before the end of the discussion period, we will not be able to update the draft immediately to reflect these changes, but **all the points discussed above will be modified considering your suggestions in the final draft.**

Best Regards,

All Authors

Reviewer comment (Experiments):
For Table 2, it would be helpful to include the baselines: (a) ERM trained on all but target domain, (b) ERM trained on all the domains, (c) ERM trained only on the target domain.

Author response:
We perform the requested experiments and report the results in the Table below (and in our updated manuscript, **Table 14**). Before consulting the results, please note the following:
1. Training on the target domains (b,c) is nonstandard in the context of SDG, as they are i.i.d. to the test sets. Thus, (b,c) do not constitute a baseline but an empirical “upper bound” on the best possible interventional augmentation strategy (i.e., where the generator can directly sample from a perfect approximation of the target distribution). 
2. Experiment (a) constitutes a typical Multi-Domain Generalization (MDG) setting that is not comparable to the SDG we focus on, as the reported metrics for the two kinds of experiments are different:
   * In MDG, ERM is trained on all but the target domain and the performance on the unseen target domain is reported (column name is unseen target domain)
   * In SDG, the average of the performance across 3 unseen target domains is reported for each known source domain (column name is the only known training domain).
Therefore the MDG results cannot be compared with the ones in Table 2 of the paper, so for a fair comparison with (a), we use SDEdit in the context of MDG (i.e., SDEdit(MDG)) using minimal prompts.


Our results are as follows:
* Unsurprisingly, (b,c) achieve near-perfect performance, confirming that the train and test datasets are nearly perfectly i.i.d.
* The performance improvement of SDEdit (MDG) with respect to (a) indicates the effectiveness of IDA also extends to the case where multiple training domains are available.


|    | Art    | Photo  | Sketch | Cartoon | Average |
|---------------|--------|--------|--------|---------|---------|
| (b)  | 99.65  | 99.94  | 99.64  | 99.66   | 99.72   |
| (c)    | 99.71  | 99.70  | 99.84  | 99.60   | 99.74   |
| (a)    | 80.01  | 96.28  | 73.86  | 76.28   | 81.61   |
| SDEdit (MDG)    | 87.5   | 95.75  | 79.21  | 85.2    | 86.91   |

Reviewer comment (Reproducibility):
There is a suspicion that implementation differences between SDEdit and others (MixUp, CutMix etc.) could be causing the massive improvement. This is a common and annoying problem with PACS and other datasets. Releasing the implementation can help verify this.

Author response:
We have integrated all baselines in the same codebase and ensured no method has an unfair edge over the others, using the same evaluation code across all methods. We have anonymized our codebase and made it available for review at https://tinyurl.com/49sb675n, and will release the de-anonymized codebase upon acceptance.

Reviewer comment (Experiments):
It would be interesting to add to Table 2 the performance of SDEdit with even more irrelevant prompts, for example using prompts from OfficeHome on PACS dataset, and compare the performance.

Author response:
We appreciate the interesting suggestion for this experiment. We added the prompts for Officehome to the ones of PACS to augment the PACS dataset. We include the results in the table below (and in **Table 4** of the revised draft) indicating this method as SDEdit(PO-M). Note that adding these “irrelevant” prompts further improves performance. 

|            | Art   | Photo | Sketch | Cartoon | Average |
|------------|-------|-------|--------|---------|---------|
| SDEdit(PO-M)| 82.41 | 65.43 | 80.3   | 85.29   | 78.36   |
| SDEdit(M)   | 82.67 | 62.94 | 73.78  | 86.33   | 76.43   |

Reviewer comment (Reproducibility):
Overall, how much effort was spent on engineering the prompts and how were they tuned?

Author response:
We asked a human participant to write up a set of prompts that would manipulate a specific feature of an image. We provided them only with information from metadata contained in the respective benchmark papers and the following high-level instructions:
* For the background-bias prompts, we asked them to specify common image backgrounds randomly. 
* For the texture-bias prompts, we asked them to reason about what kind of transformations would change the texture of an object. Later, we asked the same participant to add a few additional prompts following the same instructions (see **Appendix F.1**).
* For the demographic bias, using the meta-data of the task was enough to create “Minimal” prompts (i.e., considering all possible combinations of gender/color), so no participant was required.

The prompts were not engineered nor tuned on any metric: our goal was to evaluate how well these systems perform “off-the-shelf” (i.e., where no time was spent engineering or tuning them). This illustrates the usefulness, flexibility, and simplicity of using off-the-shelf T2I generators for RRSF.