Daniel Afrimi
Daniel Afrimi

Reputation: 45

error: unrecognized arguments: - pytorch code in colab

I tried to run my code on google colab. but I get this message (error: unrecognized arguments)when I'm trying to call this function :

def parse_opts():
 parser = argparse.ArgumentParser()
 parser.add_argument(
     '--root_path',
     default='/root/data/ActivityNet',
     type=str,
     help='Root directory path of data')
  parser.add_argument(
     '--video_path',
     default='video_kinetics_jpg',
     type=str,
     help='Directory path of Videos')
 args = parser.parse_args()

return args

but this is failed and I get this error

tester_video.py: error: unrecognized arguments: cifar_comp_20_200_0.01_0.1 20 10 0.01 0.1

I tried to use Easydict but it seems its not working thinks

Upvotes: 3

Views: 6146

Answers (2)

Joe Zhou
Joe Zhou

Reputation: 61

The problem only appears in Jupyter notebook/lab/colab.

Change

args = parser.parse_args()

to

args = parser.parse_args(args=[])

and it should fix it.

Upvotes: 5

Daniel Afrimi
Daniel Afrimi

Reputation: 45

I fixed this problem. you need to use easydict instead of argparse. insted of the code above you can write this:

args = easydict.EasyDict(
{
    "root_path": '/root/data/ActivityNet',
    "video_path": 'video_kinetics_jpg',
    "annotation_path": 'kinetics.json',
    "result_path": 'results',
    "dataset": 'kinetics',
    "n_classes": 400,
    "n_finetune_classes": 400,
    "sample_size": 64,
    "sample_duration": 32,
    "initial_scale": 1.0,
    "n_scales": 5,
    "scale_step": 0.84089641525,
    "train_crop": 'corner',
    "learning_rate": 0.1 )}

Upvotes: -1

Related Questions