3

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

Sabith
  • 1,628
  • 2
  • 20
  • 38
Daniel Afrimi
  • 35
  • 1
  • 7
  • Your code expects just two arguments, `--root_path` and `--video_path`, so you either need to extend it to accommodate other arguments or just call it with two arguments, i.e. the root and the video path. – Jan Apr 22 '19 at 11:08
  • this is not the full function, it contains more arguments. if i run this on my own CPU it works fine, but when i load it to google colaboratory for run this code on the GPU it doesn't works.. – Daniel Afrimi Apr 22 '19 at 13:53
  • 1
    Do those unrecognized arguments look like something you used in calling the script, that is, part of your command line? What does the `sys.argv` look like? Maybe those strings are meant for the `colab` environment, not your script. – hpaulj Apr 22 '19 at 16:32
  • this arguments read correctly by the command line, i checked this. this is somehow fall in the google colab when im using "argparse". my problem is similar to this one: https://stackoverflow.com/questions/48796169/how-to-fix-ipykernel-launcher-py-error-unrecognized-arguments-in-jupyter – Daniel Afrimi Apr 22 '19 at 17:18

2 Answers2

3

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.

kcdragon
  • 1,724
  • 1
  • 14
  • 23
Joe Zhou
  • 41
  • 2
-2

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 )}
Daniel Afrimi
  • 35
  • 1
  • 7