[SOLVED] TypeError: rotate() got an unexpected keyword argument 'fillcolor'

username: raj-rishav
cooked: <p>I update my torch version from 1.3.1 to 1.4.0. But the trainloader created in prior version isn’t working in v1.4.0.<br>
TypeError: rotate() got an unexpected keyword argument ‘fillcolor’</p>
<p>The above mentioned is the error. I visited the file functional.py line no - 729.<br>
The last argument used  <code>fillcolor</code> although in the function <code>rotate</code> its <code>fill</code>. I tried to make the changes but it didnt work.</p>
<p>Any help would be appreciated. Thanks</p>

username: ptrblck
cooked: <p>Could you check your <code>PIL</code> version?<br>
This argument should be passed to <code>PIL&gt;=5</code> as seen <a href="https://github.com/pytorch/vision/blob/9e8258d1506dcb0d3f2387033c1fb3242da3bd9f/torchvision/transforms/functional.py#L829">here</a>.</p>

username: raj-rishav
cooked: <p>Thanks for your reply. The PIL version is <code>5.1.0</code>. Also the <code>return</code> in the <code>rotate</code> function on my system is different than the one in the link you mentioned.<br>
For me its:<br>
<code>return img.rotate(angle, resample, expand, center, fillcolor=fill)</code><br>
Just now I uninstalled torch 1.4.0 and reinstalled it, but its the same.</p>

username: ptrblck
cooked: <p>Could you post a code snippet to reproduce this issue?<br>
This code runs fine:</p>
<pre><code class="lang-python">import torchvision.transforms.functional as TF

x = torch.randn(3, 224, 224)
img = TF.to_pil_image(x)
img = TF.rotate(img, 10)
</code></pre>

username: raj-rishav
cooked: <p>I ran the code you mentioned. It throws the following error.</p>
<pre><code class="lang-auto">TypeError                                 Traceback (most recent call last)
&lt;ipython-input-5-0f4eda8f5dd5&gt; in &lt;module&gt;
----&gt; 1 img = TF.rotate(img, 10)

/usr/local/lib/python3.6/dist-packages/torchvision/transforms/functional.py in rotate(img, angle, resample, expand, center, fill)
    727         fill = tuple([fill] * 3)
    728 
--&gt; 729     return img.rotate(angle, resample, expand, center, fillcolor=fill)
    730 
    731 

TypeError: rotate() got an unexpected keyword argument 'fillcolor'
</code></pre>

username: ptrblck
cooked: <p>I retried the code with PyTorch <code>1.4.0</code> and <code>torchvision=0.5.0</code> and it’s working fine.<br>
Could you create a new environment and reinstall both libraries?</p>

username: raj-rishav
cooked: <p>It’s working fine in the new environment. The PIL version is <code>7.0.0</code> in the environment. Updating the PIL version helped.</p>
<p>Thanks</p>

username: Naveen
cooked: <p>Hi same error my versions are below,<br>
torch 1.4.0+cpu<br>
torchvision 0.5.0+cpu</p>

username: raj-rishav
cooked: <p>Can you check the version of PIL? make sure its <code>7</code> or above. <a class="mention" href="/u/naveen">@Naveen</a></p>

username: Naveen
cooked: <p>Hi raj thank you for reply. But I am not using PIL, I am trying to do these transformation in torch.utils.data.DataLoader.</p>

username: raj-rishav
cooked: <p>I believe you didnt notice, that I was also doing the transformation thing. NOT using PIL. So can you verify the PIL version, as pytorch requires PIL.</p>