WuJie1010 / Facial-Expression-Recognition.Pytorch

A CNN based pytorch implementation on facial expression recognition (FER2013 and CK+), achieving 73.112% (state-of-the-art) in FER2013 and 94.64% in CK+ dataset
MIT License
1.78k stars 548 forks source link

h5py objects cannot be pickled #58

Closed lander1003 closed 4 years ago

lander1003 commented 4 years ago

你好,我在运行mainpro_CK+和mainpro_FER两个文件时均出现了h5py objects cannot be pickled这个报错情况,报错语句为这样for batch_idx, (inputs, targets) in enumerate(trainloader):,请问下怎么办啊,万分感谢

WuJie1010 commented 4 years ago

您是否采用了python3,如果是的话,请按照py3的要求做相应调整

lander1003 commented 4 years ago

好的,那如果用python2,用pytorch现在最新版本可以吗

lander1003 commented 4 years ago

现在python2好像安装不了pytorch了,然而python3又不知道咋改,小白表示太难了

victor-mageto commented 4 years ago

@lander1003 did you get the solution, am also facing the same error.

cimszw commented 4 years ago

@lander1003 @victor-mageto It happens because h5py won't read from multiple processes. By omitting num_workers, you're setting it to the default of 0, which uses only the main process. You could also set it to 1 (on Linux, at least). So try to set :

  1. num_workers=0.
  2. datafile = h5py.File(datapath, 'w', swmr=True) it works for me.
victor-mageto commented 4 years ago

where did you define the datapath?

lander1003 commented 4 years ago

@lander1003 did you get the solution, am also facing the same error.

I met the error when I use python3, so I change to python2

lander1003 commented 4 years ago

@lander1003 @victor-mageto It happens because h5py won't read from multiple processes. By omitting num_workers, you're setting it to the default of 0, which uses only the main process. You could also set it to 1 (on Linux, at least). So try to set :

  1. num_workers=0.
  2. datafile = h5py.File(datapath, 'w', swmr=True) it works for me.

Can have your wechat ID? I really cannot solve it by myself, I'm really new in ML.Thank you!

y894577 commented 4 years ago

我也是这个问题,有什么办法不回退到python2.7来解决这个问题么

lander1003 commented 4 years ago

我也是这个问题,有什么办法不回退到python2.7来解决这个问题么

我之前就是退回2.7搞得,要是你用python3解决了可以分享一下嘛

y894577 commented 4 years ago

我也是这个问题,有什么办法不回退到python2.7来解决这个问题么

我之前就是退回2.7搞得,要是你用python3解决了可以分享一下嘛

回退2.7会import不了torch,不知道是不是官方抛弃了2.7的问题,python3的代码也不知道从哪改,唉

lander1003 commented 4 years ago

我也是这个问题,有什么办法不回退到python2.7来解决这个问题么

我之前就是退回2.7搞得,要是你用python3解决了可以分享一下嘛

回退2.7会import不了torch,不知道是不是官方抛弃了2.7的问题,python3的代码也不知道从哪改,唉

回退到python2可能需要在linux上才能安装torch老版本了,我记得当时也是这个问题

lander1003 commented 4 years ago

我也是这个问题,有什么办法不回退到python2.7来解决这个问题么

我之前就是退回2.7搞得,要是你用python3解决了可以分享一下嘛

回退2.7会import不了torch,不知道是不是官方抛弃了2.7的问题,python3的代码也不知道从哪改,唉

可以价格wechat交流一下啊

y894577 commented 4 years ago

我也是这个问题,有什么办法不回退到python2.7来解决这个问题么

我之前就是退回2.7搞得,要是你用python3解决了可以分享一下嘛

回退2.7会import不了torch,不知道是不是官方抛弃了2.7的问题,python3的代码也不知道从哪改,唉

可以价格wechat交流一下啊

可以啊,wechat和github同账户名

ZangHuanyu commented 4 years ago

@lander1003 @victor-mageto It happens because h5py won't read from multiple processes. By omitting num_workers, you're setting it to the default of 0, which uses only the main process. You could also set it to 1 (on Linux, at least). So try to set :

  1. num_workers=0.
  2. datafile = h5py.File(datapath, 'w', swmr=True) it works for me.

Could you plz tell me where should I apply "datafile = h5py.File(datapath, 'w', swmr=True)"? Do really appreciated!

connorxian commented 3 years ago

您是否采用了python3,如果是的话,请按照py3的要求做相应调整 请问是做怎么样的调整呢

YELLOWCOOLS commented 3 years ago

datafile = h5py.File(datapath, 'w') ,witch is not used in python3. You should try use 'pickle' to save data,like this: """ train_file=open('data/fer2013/train.txt','wb') pickle.dump(Training_x,train_file) """

DaobinZhu commented 1 year ago

代码没有人维护了吗。。我遇到了相同的问题