# Domain Adaptation

Domain Adaptation can make synthetic data useful by bridging the domain gap between a digital twin camera and your sensor. Rendered.ai users train CycleGAN models for pixel level domain adaptation from raw synthetic data to domain adapted sythetic data. This tutorial will walk through the steps of uploading a GAN model to a workspace, and generating domain adapted datasets.

Read more about CycleGAN

[Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks](https://junyanz.github.io/CycleGAN/)

### Uploading a GAN Model <a href="#uploading-a-gan-model" id="uploading-a-gan-model"></a>

Rendered.ai supports PyTorch CycleGAN models for domain adaptation. Many of the models shown in the CycleGAN landing page linked above are available for download. For demonstration purposes, we will use the apple-to-orange pre-trained model available here:

[Index of /cyclegan/pretrained\_models](http://efrosgans.eecs.berkeley.edu/cyclegan/pretrained_models/)

To use the `apple2orange.pth` model, it must be added to your organization, and then associated with a workspace.

#### Add a Model to an Organization <a href="#add-a-model-to-an-organization" id="add-a-model-to-an-organization"></a>

Navigate to your organization’s GAN Models management space.

<figure><img src="/files/KkV4modrgfTBOXgyVTZQ" alt=""><figcaption><p>New GAN Model Button</p></figcaption></figure>

Under your organization (1), find the GAN Model section (2), and click the `+ New GAN Model` button (3).

<figure><img src="/files/5JtIRkBep56LLTgDeebx" alt=""><figcaption><p>New GAN Model Dialog</p></figcaption></figure>

In the new GAN model upload dialog, give the model a name and set the inference flags. The pre-trained CycleGAN models were trained with the `--no_dropout` flag, so it is required for inference.

#### Add a Model to a Workspace <a href="#add-a-model-to-a-workspace" id="add-a-model-to-a-workspace"></a>

Each workspace has various resources, such as channels, annotation maps, and GAN models. To manage these resources, navagate to the organization’s workspaces.

<figure><img src="/files/OuCGt2yWbXEv8h0pswk5" alt=""><figcaption></figcaption></figure>

From your workspaces manager, select list mode, select the three vertical dots next to the workspace you want to edit, and select the `Resources` option.

<figure><img src="/files/7car1oZJf6v3vStn1Kzo" alt=""><figcaption><p>GAN Model Manager for Content Workspace</p></figcaption></figure>

There are two models that come with the content workspace. Add the new model from the `Excluded` list to the `Included` list.

<figure><img src="/files/chF5qaC8BPKeqdtYk6e9" alt=""><figcaption><p>Apple to Orange Transfiguration Model Included</p></figcaption></figure>

Once the new model is associated with the Example workspace, click `Save`.

#### Create a Domain Adapted Dataset <a href="#create-a-domain-adapted-dataset" id="create-a-domain-adapted-dataset"></a>

The Content workspace comes pre-loaded with some datasets, and the one named `Custom Objects` is made up of images containing apples. To use the Apple to Orange Transfiguration CycleGAN model, create a GAN dataset based on `Custom Objects`.

<figure><img src="/files/OGrzdmKY45H1g6VDUQZh" alt=""><figcaption><p>Content Workspace Dataset</p></figcaption></figure>

From the Datasets tab in the Content workspace, select the `Custom Objects` dataset, and open the wizard for creating a GAN dataset.

<figure><img src="/files/z1D2bklsZzzAxZcfbYCH" alt=""><figcaption><p>Create GAN Dataset Configuration</p></figcaption></figure>

Give the new dataset a name, select the domain adaptation model, and, optionally, give it a description. When the job is complete take a look at the results.

| <p><img src="/files/jmHeYqpBuFhdLL5eS9dV" alt="" data-size="original"></p><p>Raw Synthetic Data Image</p><p> </p> | <p><img src="/files/P2EA8XyPzOkoKCq4YWTR" alt="" data-size="original"></p><p>Domain Adapted Image</p><p></p> |
| ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |

Congratulations! This model can be used in other workspaces or on other datasets. To generate GAN datasets in your ML pipeline, please take a look at our SDK.

SDK Documentation: [https://sdk.rendered.ai](https://sdk.rendered.ai/)

SDK Examples: <https://github.com/Rendered-ai/resources>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.rendered.ai/application-user-guides/tutorials/creating-and-using-datasets/domain-adaptation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
