TypeError: 'NoneType' object is not callable for transform functional

Debasmit_Das: <p>Hi,<br>
I have been trying to upload and transform images for training. I get the following error. Initially I thought that images were not getting uploaded but upon printing them they seem to be getting uploaded. So what can be the reason for the error ? Here is the output that I get -</p>
<p>/usr/local/lib/python3.6/dist-packages/torchvision/transforms/transforms.py:211: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead.<br>
“please use transforms.Resize instead.”)<br>
Saving in dir: /prj/neo_lv/user/debadas/ProtoTransfer/cdfsl-benchmark/logs/checkpoints/miniImagenet/ResNet10_prototransfer_1s_3q_aug_bs50<br>
&lt;PIL.Image.Image image mode=RGB size=280x280 at 0x7F9E105AAE48&gt;<br>
&lt;PIL.Image.Image image mode=RGB size=500x333 at 0x7F9E105AA470&gt;<br>
&lt;PIL.Image.Image image mode=RGB size=500x375 at 0x7F9E105AA128&gt;<br>
&lt;PIL.Image.Image image mode=RGB size=1070x782 at 0x7F9E1059BC88&gt;<br>
&lt;PIL.Image.Image image mode=RGB size=288x271 at 0x7F9E105AA7B8&gt;<br>
&lt;PIL.Image.Image image mode=RGB size=334x500 at 0x7F9E105AA080&gt;<br>
&lt;PIL.Image.Image image mode=RGB size=500x417 at 0x7F9E105A3DA0&gt;<br>
&lt;PIL.Image.Image image mode=RGB size=500x375 at 0x7F9E1059B9B0&gt;<br>
&lt;PIL.Image.Image image mode=RGB size=679x705 at 0x7F9E105AA550&gt;<br>
&lt;PIL.Image.Image image mode=RGB size=360x252 at 0x7F9E105AABA8&gt;<br>
&lt;PIL.Image.Image image mode=RGB size=500x375 at 0x7F9E105AAB00&gt;<br>
&lt;PIL.Image.Image image mode=RGB size=400x300 at 0x7F9E105A3A58&gt;<br>
Traceback (most recent call last):<br>
File “/prj/neo_lv/user/debadas/ProtoTransfer/cdfsl-benchmark/train.py”, line 104, in <br>
&lt;PIL.Image.Image image mode=RGB size=500x375 at 0x7F9E105AA128&gt;<br>
model = train(base_loader, model, optimization, start_epoch, stop_epoch, params)<br>
File “/prj/neo_lv/user/debadas/ProtoTransfer/cdfsl-benchmark/train.py”, line 31, in train<br>
model.train_loop(epoch, base_loader,  optimizer)<br>
File “/prj/neo_lv/user/debadas/ProtoTransfer/cdfsl-benchmark/methods/protoclr.py”, line 72, in train_loop<br>
for i, x in enumerate(train_loader):<br>
File “/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py”, line 582, in <strong>next</strong><br>
return self._process_next_batch(batch)<br>
File “/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py”, line 608, in _process_next_batch<br>
raise batch.exc_type(batch.exc_msg)<br>
TypeError: Traceback (most recent call last):<br>
File “/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/worker.py”, line 99, in _worker_loop<br>
samples = collate_fn([dataset[i] for i in batch_indices])<br>
File “/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/worker.py”, line 99, in <br>
samples = collate_fn([dataset[i] for i in batch_indices])<br>
File “/prj/neo_lv/user/debadas/ProtoTransfer/cdfsl-benchmark/datasets/miniImageNet_few_shot.py”, line 61, in <strong>getitem</strong><br>
view_list.append(self.transform(data).unsqueeze(0))<br>
File “/usr/local/lib/python3.6/dist-packages/torchvision/transforms/transforms.py”, line 61, in <strong>call</strong><br>
img = t(img)<br>
TypeError: ‘NoneType’ object is not callable</p>

Nikronic: <p>Hi, Could you share the way you constructed <code>self.transform</code> ?</p>
<aside class="quote no-group" data-username="Debasmit_Das" data-post="1" data-topic="89518">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/debasmit_das/48/26808_2.png" class="avatar"> Debasmit_Das:</div>
<blockquote>
<p>self.transform(data)</p>
</blockquote>
</aside>
<p>PS: It helps a lot if you could wrap your code in ``` like this, it enhaces readability:</p>
<pre>```
code/error
```
</pre>
<p>Bests</p>