luizgh / sigver

Signature verification package, for learning representations from signature data, training user-dependent classifiers.
BSD 3-Clause "New" or "Revised" License
82 stars 46 forks source link

Trouble executing training script train.py on CEDAR Dataset #13

Closed atinesh-s closed 4 years ago

atinesh-s commented 4 years ago

I have preprocessed CEDAR Dataset as per instructions

$ python3 -m sigver.preprocessing.process_dataset --dataset cedar --path /home/atinesh/Downloads/Datasets/CEDAR/signatures --save-path data/cedar/mcyt_170_242.npz

Processing dataset
Number of users: 55
Allocated x of shape: (2640, 170, 242)
 51%|████████████████████████████████▌                               | 28/55 [00:27<00:24,  1.09it/s]/home/atinesh/Desktop/virtual_envs/pytorch_env/lib/python3.6/site-packages/skimage/util/dtype.py:135: UserWarning: Possible precision loss when converting from float64 to uint8
  .format(dtypeobj_in, dtypeobj_out))
100%|████████████████████████████████████████████████████████████████| 55/55 [00:54<00:00,  1.01it/s]

But when I try to run train.py by the following command

$ python3 -m sigver.featurelearning.train --model signet --dataset-path data/cedar/mcyt_170_242.npz --users 1 55 --model signet --epochs 10 --logdir signet

I get error in util.py

train.py, line 330, in main
x, y, yforg, usermapping, filenames = util.load_dataset(args.dataset_path)

util.py, line 31, in load_dataset
user_mapping, filenames = data['user_mapping'], data['filenames']

ValueError: Object arrays cannot be loaded when allow_pickle=False
luizgh commented 4 years ago

Hello @atinesh-s, thanks for bringing it up. This is something another user has noticed, and created a bugfix. I just merged the change - can you please get the new version and try again?

atinesh-s commented 4 years ago

Hello @atinesh-s, thanks for bringing it up. This is something another user has noticed, and created a bugfix. I just merged the change - can you please get the new version and try again?

Hello @luizgh, With new code old bug has been resolved but I was getting another error in train.py at Line-305 while training signet model

return val_acc.item(), val_loss.item(), val_forg_acc.item(), val_forg_loss.item()

AttributeError: 'float' object has no attribute 'item'

For the signet model val_forg_acc and val_forg_loss will be nan hence the error is obvious. Anyway, I changed that line as below and now code is running without any problem

return val_acc, val_loss, val_forg_acc, val_forg_loss

luizgh commented 4 years ago

That makes sense - the lists val_losses, etc. already get the only the value from the torch tensor (e.g. loss.item(). Can you create a pull request with this change?

gonultasbu commented 4 years ago

There is an open pull request by me to fix this issue.

https://github.com/luizgh/sigver/pull/9

atinesh-s commented 4 years ago

There is an open pull request by me to fix this issue.

9

Hi @gonultasbu , Why not

return val_acc, val_loss, val_forg_acc, val_forg_loss

Instead of

if is_forg: return val_acc.item(), val_loss.item(), val_forg_acc.item(), val_forg_loss.item()
    else : return val_acc.item(), val_loss.item(), val_forg_acc, val_forg_loss

that will be more cleaner I believe.

gonultasbu commented 4 years ago

@atinesh-s it caused some issues with forgeries enabled, if my memory serves, been a while since I opened that PR.

atinesh-s commented 4 years ago

@atinesh-s it caused some issues with forgeries enabled, if my memory serves, been a while since I opened that PR.

I have ran both model signet and signet-f its working fine

gonultasbu commented 4 years ago

@atinesh-s if the code works with the following set of arguments:

python -m sigver.featurelearning.train --model signet --dataset-path <data.npz> --users [first last]\ --model signet --epochs 60 --forg --lamb 0.95 --logdir signet_f_lamb0.95

I guess that might also be a viable solution. I don't have the necessary resources to go back and verify.

Bear in mind that the PR also contains a fix for visdom.

atinesh-s commented 4 years ago

@atinesh-s if the code works with the following set of arguments:

python -m sigver.featurelearning.train --model signet --dataset-path <data.npz> --users [first last]\ --model signet --epochs 60 --forg --lamb 0.95 --logdir signet_f_lamb0.95

I guess that might also be a viable solution. I don't have the necessary resources to go back and verify.

Bear in mind that the PR also contains a fix for visdom.

I have ran and tested code only on CEDAR Dataset.

luizgh commented 4 years ago

@gonultasbu - that has been a while, I completely forgot about these PRs, sorry about that!

For the fix with the return value (val_fog_loss.item), I prefer the solution from @atinesh-s , and just get rid of the ".item()" (since this is called above, before adding them to the lists). I merged that pull request

@gonultasbu Can you create a PR with just the visdom change?

gonultasbu commented 4 years ago

@luizgh I will do it when I have time, also need to resolve some conflicts I assume.

gonultasbu commented 4 years ago

@luizgh #15

luizgh commented 4 years ago

Thanks @gonultasbu - I merged the PR

devendraswamy commented 4 years ago

for cedar dataset , what is the range of --user ?? HELP me.

natures --save-path /home/dell/Documents/Prasad_AI/sign_similarity/sigver/changed_data Processing dataset Number of users: 55 Allocated x of shape: (2640, 170, 242)

luizgh commented 4 years ago

It depends on your setup. If you want to use all users to learn features, use --users 0 55