clean-fid icon indicating copy to clipboard operation
clean-fid copied to clipboard

AttributeError: Can't pickle local object 'make_resizer.<locals>.func'

Open zhehaoli1999 opened this issue 2 years ago • 2 comments

Env: python 3.9.6, clean-fid: 0.1.15 My code:

from cleanfid import fid
score = fid.compute_fid('./fake_images', '../real_images')

Error:

  File "C:\Users\10034\AppData\Local\Programs\Python\Python39\lib\site-packages\cleanfid\fid.py", line 389, in compute_fid
    score = compare_folders(fdir1, fdir2, feat_model,
  File "C:\Users\10034\AppData\Local\Programs\Python\Python39\lib\site-packages\cleanfid\fid.py", line 238, in compare_folders
    np_feats1 = get_folder_features(fdir1, feat_model, num_workers=num_workers,
  File "C:\Users\10034\AppData\Local\Programs\Python\Python39\lib\site-packages\cleanfid\fid.py", line 131, in get_folder_features
    np_feats = get_files_features(files, model, num_workers=num_workers,
  File "C:\Users\10034\AppData\Local\Programs\Python\Python39\lib\site-packages\cleanfid\fid.py", line 109, in get_files_features
    for batch in tqdm(dataloader, desc=description):
  File "C:\Users\10034\AppData\Local\Programs\Python\Python39\lib\site-packages\tqdm\std.py", line 1180, in __iter__
    for obj in iterable:
  File "C:\Users\10034\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\data\dataloader.py", line 359, in __iter__
    return self._get_iterator()
  File "C:\Users\10034\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\data\dataloader.py", line 305, in _get_iterator
    return _MultiProcessingDataLoaderIter(self)
  File "C:\Users\10034\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\data\dataloader.py", line 918, in __init__
    w.start()
  File "C:\Users\10034\AppData\Local\Programs\Python\Python39\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "C:\Users\10034\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Users\10034\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 327, in _Popen
    return Popen(process_obj)
  File "C:\Users\10034\AppData\Local\Programs\Python\Python39\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
    reduction.dump(process_obj, to_child)
  File "C:\Users\10034\AppData\Local\Programs\Python\Python39\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'make_resizer.<locals>.func'

zhehaoli1999 avatar Jan 17 '22 03:01 zhehaoli1999

Hi,

Thank you for raising this concern. Can you try the newer clean-fid version 0.1.16 and an additional flag num_workers=0?

Regards, Gaurav

GaParmar avatar Jan 17 '22 20:01 GaParmar

Hi,

Thank you for raising this concern. Can you try the newer clean-fid version 0.1.16 and an additional flag num_workers=0?

Regards, Gaurav

score = fid.compute_fid(fdir1, fdir2, mode="clean", num_workers=0) Solved the problem.

rickkk856 avatar Mar 04 '22 12:03 rickkk856