# Domain Gap Analysis

### **What Is Domain Gap and Why It Matters**

A domain gap occurs when a model performs differently across distinct data distributions — for example, between synthetic and real-world data, or between data captured by different hardware. These performance drops often stem from subtle but impactful changes in the input space, such as lighting, compression, or scene content.

Understanding *that* a gap exists is not enough. To address it effectively, teams need to understand *why* it exists — in terms of **quantifiable, input-level differences** that drive the model's behavior.

This enables targeted mitigation strategies, like collecting specific new data, refining labeling, or applying domain adaptation techniques in a controlled way.

#### **How Tensorleap Helps Analyze and Mitigate Domain Gap**

**1. Measure Domain Gap in Latent Space**

Tensorleap computes the distance between domains in the model’s latent space. This allows users to:

* Quantify whether two domains are semantically different from the model’s perspective
* Rapidly test hypotheses by applying changes and re-measuring the latent shift
* Identify specific concepts that are missing or distorted in one domain

<figure><img src="https://3509361326-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9UXeOlFqlw8pl79U2HGU%2Fuploads%2Fml2JUk1DMAY9336YUGiG%2FKapture%202025-07-07%20at%2010.39.11.gif?alt=media&#x26;token=540974f2-1a4a-4d08-8fec-ec38c5782e3c" alt=""><figcaption><p>The Tensorleap platform computes latent space distances on selected domains to quantify the domain gap</p></figcaption></figure>

**2. Explore Metadata Distributions Between Domains**

Tensorleap surfaces metadata differences across domains — whether manually added (e.g. “ISP type”) or automatically derived.

This helps uncover input-level shifts that might explain the gap:

* Exposure or lighting distributions
* Device-specific compression patterns
* Scene or location types

<figure><img src="https://3509361326-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9UXeOlFqlw8pl79U2HGU%2Fuploads%2FhywlcIAKgcYCs76zqfDU%2Fimage.png?alt=media&#x26;token=292d967e-1308-46a8-b7a8-b32d767742ad" alt=""><figcaption><p>The KITTI and Cityscape dataset has a different distribution of vegetation pixels. The former is more rural and contains a higher % of vegetation, while the latter is more urban and thus contain less vegetation</p></figcaption></figure>

**3. Use Heatmaps to Understand Domain-Specific Focus**

By comparing input-level heatmaps across domains, Tensorleap reveals:

* What features the model focuses on in each domain
* Whether the model relies on domain-specific artifacts or irrelevant cues
* Potential blind spots or missing context in one domain

<figure><img src="https://3509361326-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9UXeOlFqlw8pl79U2HGU%2Fuploads%2FYIPE5ygFnNSYDWvffUU7%2Fimage.png?alt=media&#x26;token=3f403bb2-09ae-46b2-b3b9-86d87f07818d" alt=""><figcaption><p>A scene from cityscapes (bottom) and from KITTI (top) overlayed with the main features from each scene.</p></figcaption></figure>

### **Domain Gap Walkthrough**

Coming Soon
