AssertionError: force_apply must have bool or int type

0%| | 0/782 [00:00<?, ?it/s]

AssertionError Traceback (most recent call last)
in
1 for epoch in range(2):
----> 2 train(net, device, optimizer,criterion, epoch,trainloader)
3 test(net, device, criterion,testloader)

~\Documents\Gaju_data\Quest\eva4\S9\utils\train.py in train(net, device, optimizer, criterion, epoch, trainloader)
42 correct = 0
43 processed = 0
—> 44 for batch_idx, (input, labels) in enumerate(pbar):
45 # get samples
46 input, labels = input.to(device), labels.to(device)

C:\ProgramData\Anaconda3\lib\site-packages\tqdm\std.py in iter(self)
1079 “”"), fp_write=getattr(self.fp, ‘write’, sys.stderr.write))
1080
-> 1081 for obj in iterable:
1082 yield obj
1083 # Update and possibly print the progressbar.

C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py in next(self)
344 def next(self):
345 index = self._next_index() # may raise StopIteration
–> 346 data = self.dataset_fetcher.fetch(index) # may raise StopIteration
347 if self.pin_memory:
348 data = _utils.pin_memory.pin_memory(data)

C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\data_utils\fetch.py in fetch(self, possibly_batched_index)
42 def fetch(self, possibly_batched_index):
43 if self.auto_collation:
—> 44 data = [self.dataset[idx] for idx in possibly_batched_index]
45 else:
46 data = self.dataset[possibly_batched_index]

C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\data_utils\fetch.py in (.0)
42 def fetch(self, possibly_batched_index):
43 if self.auto_collation:
—> 44 data = [self.dataset[idx] for idx in possibly_batched_index]
45 else:
46 data = self.dataset[possibly_batched_index]

C:\ProgramData\Anaconda3\lib\site-packages\torchvision\datasets\cifar.py in getitem(self, index)
123
124 if self.transform is not None:
–> 125 img = self.transform(img)
126
127 if self.target_transform is not None:

~\Documents\Gaju_data\Quest\eva4\S9\albumentations\core\composition.py in call(self, force_apply, **data)
162
163 def call(self, force_apply=False, **data):
–> 164 assert isinstance(force_apply, (bool, int)), “force_apply must have bool or int type”
165 need_to_run = force_apply or random.random() < self.p
166 for p in self.processors.values():

AssertionError: force_apply must have bool or int type

i’m facing issue with albumentations.

https://albumentations.readthedocs.io/en/latest/_modules/albumentations/core/composition.html

I faced the same issue, the solution is simple:

   sample = {'image':image, 'label':label}

    if self.transform:
        sample = self.transform(**sample)

notice the ** in self.transform

I am having the same issue can you please explain more your solution

sample = self.transform(**sample)

by using **samples unpacks a dictionary into keyword arguments.

Please ref the below link, that help us to understand more on python unpacking

** Unpacking