When Domain Generalization meets Generalized Category Discovery: An Adaptive Task-Arithmetic Driven Approach

Vaibhav Rathore, Shubhranil B, Saikat Dutta, Sarthak Mehrotra, Zsolt Kira, Biplab Banerjee

Abstract

Generalized Category Discovery (GCD) aims to identify both known and novel object categories in a target dataset. However, existing GCD methods typically assume that the target domain is available during training or that there is no significant distribution shift between training and testing. This paper introduces a more realistic and challenging setting: Domain Generalization for Generalized Category Discovery (DG-GCD). In this setting, a model is trained on a labeled source domain and must generalize to categorize both known and novel classes in a completely unseen target domain. We propose DG$^2$CD-Net, a framework that leverages synthetic domain generation via diffusion models and an adaptive task-arithmetic weight-merging strategy. Our approach achieves state-of-the-art performance across multiple benchmarks, demonstrating robust discovery capabilities under significant distribution shifts.

1. Introduction

Traditional computer vision models are often limited to "closed-set" tasks, where they recognize only a fixed set of categories seen during training. Generalized Category Discovery (GCD) extends this by requiring models to cluster both known ("base") classes and previously unseen ("novel") classes in a target dataset. Despite its utility, GCD has a significant limitation: it assumes the target domain is accessible during training or that the domain shift is negligible.

In real-world applications, such as autonomous driving or robotics, models frequently encounter environments (e.g., different weather conditions or geographic locations) that were not present in the training data. To address this, we define the DG-GCD task. Here, the model is trained strictly on a labeled source domain and must perform category discovery on visually distinct, unseen target domains at inference time.

2. Methodology: The DG$^2$CD-Net Framework

To tackle the DG-GCD problem, we introduce DG$^2$CD-Net, which incorporates three primary innovations designed to enhance domain invariance and category discrimination.

2.1 Synthetic Domain Generation

Since the target domain is unknown during training, we utilize a foundation model (Instruct-Pix2Pix) to "hallucinate" diverse synthetic domains. By applying text-based prompts (e.g., "Add snowy scene," "Make it night-time") to source images, we create a proxy for the environmental variety the model will encounter in the wild. This synthetic diversity serves as a critical engine for generalization.

2.2 Progressive Episodic Training

The model is trained using a progressive episodic approach. In each episode, the model solves a mini-GCD task using a combination of source and synthetic data. This process encourages the model to learn features that are invariant to domain-specific styles while remaining highly discriminative for object categories.

2.3 Adaptive Task Arithmetic (TA)

Rather than relying solely on standard gradient descent, which can lead to "gradient interference" in multi-task settings, we employ Task Arithmetic. We fine-tune several "local" models on different episodic tasks and calculate a task vector (the difference between pre-trained and fine-tuned weights) for each. These vectors are merged into a global model using a dynamic weighting scheme based on validation performance. This reduces sign conflicts between updates and improves the stability of the global model.

2.4 Novel Margin Loss

To prevent the model from confusing fine-grained novel classes with known base classes, we introduce a margin-based objective. This loss function explicitly pushes novel class clusters away from the feature space occupied by known classes, facilitating clearer separation in the embedding space.

3. Experimental Evaluation

We evaluated DG$^2$CD-Net on three standard domain generalization benchmarks repurposed for the GCD task:

  • PACS: (Photo, Art, Cartoon, Sketch) - 7 classes across 4 domains.
  • Office-Home: 65 classes across 4 domains.
  • DomainNet: A large-scale dataset with 345 classes across 6 domains.

In each experiment, one domain served as the source, while the remaining domains were treated as unseen targets.

3.1 Key Results

DG$^2$CD-Net significantly outperformed existing GCD and Domain Adaptation baselines:

  • Accuracy: On the PACS dataset, DG$^2$CD-Net achieved an average accuracy of 73.3%, a substantial improvement over the 52.3% achieved by standard GCD methods.
  • Scalability: The model maintained superior performance on the massive DomainNet dataset, proving its effectiveness in high-dimensional category spaces.
  • Efficiency: We also implemented a LoRA (Low-Rank Adaptation) version of the framework. This variant achieved nearly identical performance while training only 0.115% of the total parameters, highlighting the framework's potential for resource-constrained applications.

4. Discussion and Conclusion

Our findings demonstrate that synthetic data generation via diffusion models is a powerful tool for generalization, outperforming traditional augmentations like color jittering. Furthermore, the use of Task Arithmetic for weight merging provides a more stable path for multi-domain learning than standard multi-task optimization.

While the computational cost of diffusion-based generation and episodic training is higher than standard methods, the gains in robustness and discovery accuracy are significant. Future work will focus on streamlining synthetic data generation and addressing class imbalance within the DG-GCD setting. In conclusion, DG$^2$CD-Net provides a robust foundation for AI systems that must navigate and understand an ever-changing, open-world environment.

Summary updated

BibTeX
@inproceedings{rathore2025when,
  author = {Vaibhav Rathore and Shubhranil B and Saikat Dutta and Sarthak Mehrotra and Zsolt Kira and Biplab Banerjee},
  title = {{When Domain Generalization meets Generalized Category Discovery: An Adaptive Task-Arithmetic Driven Approach}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.00462},
}
Figure