Crop_pad function

Hello,

I do not know what I’m doing wrong, but. it looks like the problem is with crop_pad function.
below the notebook

f_model = models.resnet34(pretrained=True)
sz=224
bs=64
tfms = get_transforms()
md = ImageDataBunch.from_csv(path, 'JPEGImages', csv_labels='tmp/lrg.csv', ds_tfms=tfms, size=sz, bs=bs)
md.batch_stats()
---------------------------------------------------------------------------

PicklingError                             Traceback (most recent call last)

<ipython-input-43-dcefd306b14f> in <module>()
----> 1 md.batch_stats()


~\AppData\Local\Continuum\anaconda3\lib\site-packages\fastai\vision\data.py in batch_stats(self, funcs)
    164         "Grab a batch of data and call reduction function `func` per channel"
    165         funcs = ifnone(funcs, [torch.mean,torch.std])
--> 166         x = self.one_batch(ds_type=DatasetType.Valid, denorm=False)[0].cpu()
    167         return [func(channel_view(x), 1) for func in funcs]
    168 


~\AppData\Local\Continuum\anaconda3\lib\site-packages\fastai\basic_data.py in one_batch(self, ds_type, detach, denorm)
    134         w = self.num_workers
    135         self.num_workers = 0
--> 136         try:     x,y = next(iter(dl))
    137         finally: self.num_workers = w
    138         if detach: x,y = to_detach(x),to_detach(y)


~\AppData\Local\Continuum\anaconda3\lib\site-packages\fastai\basic_data.py in __iter__(self)
     68     def __iter__(self):
     69         "Process and returns items from `DataLoader`."
---> 70         for b in self.dl:
     71             y = b[1][0] if is_listy(b[1]) else b[1]
     72             yield self.proc_batch(b)


~\AppData\Local\Continuum\anaconda3\lib\site-packages\torch\utils\data\dataloader.py in __iter__(self)
    499 
    500     def __iter__(self):
--> 501         return _DataLoaderIter(self)
    502 
    503     def __len__(self):


~\AppData\Local\Continuum\anaconda3\lib\site-packages\torch\utils\data\dataloader.py in __init__(self, loader)
    287             for w in self.workers:
    288                 w.daemon = True  # ensure that the worker exits on process exit
--> 289                 w.start()
    290 
    291             _update_worker_pids(id(self), tuple(w.pid for w in self.workers))


~\AppData\Local\Continuum\anaconda3\lib\multiprocessing\process.py in start(self)
    110                'daemonic processes are not allowed to have children'
    111         _cleanup()
--> 112         self._popen = self._Popen(self)
    113         self._sentinel = self._popen.sentinel
    114         # Avoid a refcycle if the target function holds an indirect


~\AppData\Local\Continuum\anaconda3\lib\multiprocessing\context.py in _Popen(process_obj)
    221     @staticmethod
    222     def _Popen(process_obj):
--> 223         return _default_context.get_context().Process._Popen(process_obj)
    224 
    225 class DefaultContext(BaseContext):


~\AppData\Local\Continuum\anaconda3\lib\multiprocessing\context.py in _Popen(process_obj)
    320         def _Popen(process_obj):
    321             from .popen_spawn_win32 import Popen
--> 322             return Popen(process_obj)
    323 
    324     class SpawnContext(BaseContext):


~\AppData\Local\Continuum\anaconda3\lib\multiprocessing\popen_spawn_win32.py in __init__(self, process_obj)
     63             try:
     64                 reduction.dump(prep_data, to_child)
---> 65                 reduction.dump(process_obj, to_child)
     66             finally:
     67                 set_spawning_popen(None)


~\AppData\Local\Continuum\anaconda3\lib\multiprocessing\reduction.py in dump(obj, file, protocol)
     58 def dump(obj, file, protocol=None):
     59     '''Replacement for pickle.dump() using ForkingPickler.'''
---> 60     ForkingPickler(file, protocol).dump(obj)
     61 
     62 #


PicklingError: Can't pickle <function crop_pad at 0x000002C8154EB840>: it's not the same object as fastai.vision.transform.crop_pad

thank you in advance :slight_smile:

1 Like