AssertionError: force_apply must have bool or int type

username: Gaju27
cooked: <h2>0%|                                                                                          | 0/782 [00:00&lt;?, ?it/s]</h2>
<p>AssertionError                            Traceback (most recent call last)<br>
 in <br>
1 for epoch in range(2):<br>
----&gt; 2     train(net, device, optimizer,criterion, epoch,trainloader)<br>
3     test(net, device, criterion,testloader)</p>
<p>~\Documents\Gaju_data\Quest\eva4\S9\utils\train.py in train(net, device, optimizer, criterion, epoch, trainloader)<br>
42   correct = 0<br>
43   processed = 0<br>
—&gt; 44   for batch_idx, (input, labels) in enumerate(pbar):<br>
45     # get samples<br>
46     input, labels = input.to(device), labels.to(device)</p>
<p>C:\ProgramData\Anaconda3\lib\site-packages\tqdm\std.py in <strong>iter</strong>(self)<br>
1079             “”"), fp_write=getattr(self.fp, ‘write’, sys.stderr.write))<br>
1080<br>
-&gt; 1081         for obj in iterable:<br>
1082             yield obj<br>
1083             # Update and possibly print the progressbar.</p>
<p>C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py in <strong>next</strong>(self)<br>
344     def <strong>next</strong>(self):<br>
345         index = self._next_index()  # may raise StopIteration<br>
–&gt; 346         data = self.dataset_fetcher.fetch(index)  # may raise StopIteration<br>
347         if self.pin_memory:<br>
348             data = _utils.pin_memory.pin_memory(data)</p>
<p>C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\data_utils\fetch.py in fetch(self, possibly_batched_index)<br>
42     def fetch(self, possibly_batched_index):<br>
43         if self.auto_collation:<br>
—&gt; 44             data = [self.dataset[idx] for idx in possibly_batched_index]<br>
45         else:<br>
46             data = self.dataset[possibly_batched_index]</p>
<p>C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\data_utils\fetch.py in (.0)<br>
42     def fetch(self, possibly_batched_index):<br>
43         if self.auto_collation:<br>
—&gt; 44             data = [self.dataset[idx] for idx in possibly_batched_index]<br>
45         else:<br>
46             data = self.dataset[possibly_batched_index]</p>
<p>C:\ProgramData\Anaconda3\lib\site-packages\torchvision\datasets\cifar.py in <strong>getitem</strong>(self, index)<br>
123<br>
124         if self.transform is not None:<br>
–&gt; 125             img = self.transform(img)<br>
126<br>
127         if self.target_transform is not None:</p>
<p>~\Documents\Gaju_data\Quest\eva4\S9\albumentations\core\composition.py in <strong>call</strong>(self, force_apply, **data)<br>
162<br>
163     def <strong>call</strong>(self, force_apply=False, **data):<br>
–&gt; 164         assert isinstance(force_apply, (bool, int)), “force_apply must have bool or int type”<br>
165         need_to_run = force_apply or random.random() &lt; self.p<br>
166         for p in self.processors.values():</p>
<p>AssertionError: force_apply must have bool or int type</p>

username: Gaju27
cooked: <p>i’m facing issue with albumentations.</p>
<p><a href="https://albumentations.readthedocs.io/en/latest/_modules/albumentations/core/composition.html" class="onebox" target="_blank" rel="nofollow noopener">https://albumentations.readthedocs.io/en/latest/_modules/albumentations/core/composition.html</a></p>

username: Alberto_Albiol
cooked: <p>I faced the same issue, the solution is simple:</p>
<pre><code>   sample = {'image':image, 'label':label}

    if self.transform:
        sample = self.transform(**sample)
</code></pre>
<p>notice the ** in self.transform</p>

username: Maryam_M
cooked: <aside class="quote no-group" data-username="Solved by Alberto_Albiol in post #3" data-post="3" data-topic="73345">
<div class="title">
<div class="quote-controls"></div>
 Solved by Alberto_Albiol in post #3:</div>
<blockquote>
<p>sample</p>
</blockquote>
</aside>
<p>I am having the same issue can you please explain more your solution</p>

username: Gaju27
cooked: <p>sample = self.transform(**sample)</p>
<p>by using **samples unpacks a dictionary into keyword arguments.</p>
<p>Please ref the below link,  that help us to understand more on python unpacking</p>
<p><a href="https://stackoverflow.com/questions/11315010/what-do-and-before-a-variable-name-mean-in-a-function-signature" rel="noopener nofollow ugc">** Unpacking</a></p>