<p>No, this is not what the Transformer module does. The Transformer is primarily used for pre-training general use models for NLP on large bodies of text. If you're curious to learn more, I strongly recommend you read the article which introduced the architecture, <a href="https://arxiv.org/abs/1706.03762" rel="nofollow noreferrer">"Attention is All You Need"</a>. If you've heard of models like <a href="https://github.com/huggingface/transformers" rel="nofollow noreferrer">BERT or GPT-2</a>, these are examples of transformers.</p>

<p>It's not entirely clear what you are trying to accomplish when you ask how to "transform an image into another image." I'm thinking maybe you are looking for something this? <a href="https://junyanz.github.io/CycleGAN/" rel="nofollow noreferrer">https://junyanz.github.io/CycleGAN/</a></p>

<p>In any event, to re-answer your question: no, that's not how you use nn.Transformer. You should try to clarify what you are trying to accomplish with "transforming one picture into another," and post that description as a separate question.</p>
Is this how nn.Transformer works?
<p>If I want to transform an image to another image,
then</p>

<pre><code>transformer_model = nn.Transformer(img_size, n_heads)
transformer_model(source_image, target_image)
</code></pre>

<p>is this the correct way to use nn.Transformer?</p>