HomoInterpGAN icon indicating copy to clipboard operation
HomoInterpGAN copied to clipboard

TypeError: '>' not supported between instances of 'str' and 'int'

Open PeterouZh opened this issue 6 years ago • 6 comments

I encountered this error when I tried to execute the training script. The line of code that caused the exception is seen here url. I am looking forward to your help.

Below is the detailed error message:

/home/shhs/anaconda3/envs/torch_1_0_py3_6/bin/python /home.bak/shhs/soft/pycharm-2019.1.1/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 46783 --file /media/shhs/Peterou2/user/code/HomoInterpGAN/run.py attribute_manipulation -bs 8 -gpu 0 pydev debugger: process 6843 is connecting

Connected to pydev debugger (build 191.6605.12) loading default VGG

  • Total Images: 162770 Traceback (most recent call last): File "/home.bak/shhs/soft/pycharm-2019.1.1/helpers/pydev/pydevd.py", line 1741, in main() File "/home.bak/shhs/soft/pycharm-2019.1.1/helpers/pydev/pydevd.py", line 1735, in main globals = debugger.run(setup['file'], None, None, is_module) File "/home.bak/shhs/soft/pycharm-2019.1.1/helpers/pydev/pydevd.py", line 1135, in run pydev_imports.execfile(file, globals, locals) # execute the script File "/home.bak/shhs/soft/pycharm-2019.1.1/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/media/shhs/Peterou2/user/code/HomoInterpGAN/run.py", line 205, in engine.run() File "/media/shhs/Peterou2/user/code/HomoInterpGAN/run.py", line 200, in run exec ('self.{}()'.format(self.args.command)) File "", line 1, in File "/media/shhs/Peterou2/user/code/HomoInterpGAN/run.py", line 161, in attribute_manipulation _, test_dataset = self.load_dataset() File "/media/shhs/Peterou2/user/code/HomoInterpGAN/run.py", line 106, in load_dataset csv_path='info/celeba-with-orientation.csv') File "/media/shhs/Peterou2/user/code/HomoInterpGAN/data/attributeDataset.py", line 220, in init f3 = self.frame.iloc[:, 1:] > 0 File "/home/shhs/anaconda3/envs/torch_1_0_py3_6/lib/python3.6/site-packages/pandas/core/ops.py", line 2108, in f res = self._combine_const(other, func) File "/home/shhs/anaconda3/envs/torch_1_0_py3_6/lib/python3.6/site-packages/pandas/core/frame.py", line 5120, in _combine_const return ops.dispatch_to_series(self, other, func) File "/home/shhs/anaconda3/envs/torch_1_0_py3_6/lib/python3.6/site-packages/pandas/core/ops.py", line 1157, in dispatch_to_series new_data = expressions.evaluate(column_op, str_rep, left, right) File "/home/shhs/anaconda3/envs/torch_1_0_py3_6/lib/python3.6/site-packages/pandas/core/computation/expressions.py", line 208, in evaluate return _evaluate(op, op_str, a, b, **eval_kwargs) File "/home/shhs/anaconda3/envs/torch_1_0_py3_6/lib/python3.6/site-packages/pandas/core/computation/expressions.py", line 68, in _evaluate_standard return op(a, b) File "/home/shhs/anaconda3/envs/torch_1_0_py3_6/lib/python3.6/site-packages/pandas/core/ops.py", line 1128, in column_op for i in range(len(a.columns))} File "/home/shhs/anaconda3/envs/torch_1_0_py3_6/lib/python3.6/site-packages/pandas/core/ops.py", line 1128, in for i in range(len(a.columns))} File "/home/shhs/anaconda3/envs/torch_1_0_py3_6/lib/python3.6/site-packages/pandas/core/ops.py", line 1766, in wrapper res = na_op(values, other) File "/home/shhs/anaconda3/envs/torch_1_0_py3_6/lib/python3.6/site-packages/pandas/core/ops.py", line 1625, in na_op result = _comp_method_OBJECT_ARRAY(op, x, y) File "/home/shhs/anaconda3/envs/torch_1_0_py3_6/lib/python3.6/site-packages/pandas/core/ops.py", line 1603, in _comp_method_OBJECT_ARRAY result = libops.scalar_compare(x, y, op) File "pandas/_libs/ops.pyx", line 97, in pandas._libs.ops.scalar_compare TypeError: '>' not supported between instances of 'str' and 'int'

PeterouZh avatar Jul 05 '19 06:07 PeterouZh

Hi @PeterouZh, I think the reason might be that f3 parse "-1" as string instead of int. Can you try to replace that line with f3 = self.frame.replace(-1, 0) or f3 = self.frame.replace("-1", 0)? Please let me know whether it works or not.

yingcong avatar Jul 08 '19 23:07 yingcong

Hi @yingcong , I'm facing the same problem, and I tried your method to solve it. But after change that line, it keeps run time error at the start of training(showing "stack overflow") Then follows lots of lines of "***********/data/attributeDataset.py", line 244 in __getitem__" Here's some first lines of the error message.

loading default VGG
loading default VGG
loading default VGG
* Total Images: 162770
* Total Images: 19962
save_dir: checkpoints/CelebA_my
n_discrim: 5
command: train
gpu: 0
batch_size: 128
data_dir: ../celebra-dataset
attr: Mouth_Slightly_Open@Smiling,Male@No_Beard@Mustache@Goatee@Sideburns,Black_Hair@Blond_Hair@Brown_Hair@Gray_Hair,Bald@Receding_Hairline@Bangs,Young
dec_type: v1
continue_train: False
epoch: 10000

  0%|                                                                                                                                                                        | 0/1271 [00:00<?, ?it/s]Fatal Python error: Cannot recover from stack overflow.

Current thread 0x00007f8675a0b740 (most recent call first):
  File "/....../HomoInterpGAN/util/util.py", line 144 in readRGB
  File "/....../HomoInterpGAN/data/attributeDataset.py", line 244 in __getitem__
  File "/....../HomoInterpGAN/data/attributeDataset.py", line 266 in __getitem__
  File "/....../HomoInterpGAN/data/attributeDataset.py", line 266 in __getitem__
  File "/....../HomoInterpGAN/data/attributeDataset.py", line 266 in __getitem__
  File "/....../HomoInterpGAN/data/attributeDataset.py", line 266 in __getitem__
......

I'm using pytorch 1.0.1 with cuda 9.1, other modules are installed as requirement.txt I'm looking forward to your help, thanks!

oscardhc avatar Jul 15 '19 02:07 oscardhc

Hi @oscardhc It seems that images are not successfully loaded with getitem. Have you checked if the celeba images (jpg format) are in the ../celebra-dataset file? If yes, could you remove the "try -- except" block in the getitem method? This could give more information about why images cannot be loaded.

yingcong avatar Jul 15 '19 06:07 yingcong

@yingcong Thank you for the advice! It turns out that I've put all images in a subdirectory in the dataset path(as the default result of unzipping). After moving the images, your solutions above work and it starts to train.

oscardhc avatar Jul 15 '19 10:07 oscardhc

I fix this issue by replacing "f3 = self.frame.iloc[:, 1:] > 0" url with "f3 = self.frame.iloc[:, 3:-1] > 0".

PeterouZh avatar Jul 16 '19 12:07 PeterouZh

Hi @PeterouZh I've replaced f3 = self.frame.iloc[:, 1:] > 0 with f3 = self.frame.replace(-1, 0) in the later commit, which seems more general for different pandas versions.

yingcong avatar Jul 17 '19 03:07 yingcong