camel007/caffe2-mobilenet

missing is_test argument to AddImageInput

dzung-hoang opened this issue · 0 comments

I got this error when running the script using a recent version of caffe2 from pytorch.

Ignoring @/caffe2/caffe2/contrib/nccl:nccl_ops as it is not a valid file.
Ignoring @/caffe2/caffe2/contrib/gloo:gloo_ops as it is not a valid file.
Ignoring @/caffe2/caffe2/contrib/gloo:gloo_ops_gpu as it is not a valid file.
Ignoring /home/nd/caffe2_set/caffe2/caffe2/distributed:file_store_handler_ops as it is not a valid file.
Ignoring /home/nd/caffe2_set/caffe2/caffe2/distributed:redis_store_handler_ops as it is not a valid file.
INFO:mobilenet_trainer:Running on GPUs: [0]
INFO:mobilenet_trainer:Using epoch size: 49920
INFO:data_parallel_model:Parallelizing model for devices: [0]
INFO:data_parallel_model:Create input and model training operators
INFO:data_parallel_model:Model for GPU : 0
Traceback (most recent call last):
  File "mobile_net_trainer.py", line 472, in <module>
    main()
  File "mobile_net_trainer.py", line 465, in main
    Train(args)
  File "mobile_net_trainer.py", line 314, in Train
    optimize_gradient_memory=True,
  File "/usr/local/lib/python2.7/dist-packages/caffe2/python/data_parallel_model.py", line 34, in Parallelize_GPU
    Parallelize(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/caffe2/python/data_parallel_model.py", line 219, in Parallelize
    input_builder_fun(model_helper_obj)
  File "mobile_net_trainer.py", line 303, in add_image_input
    img_size=args.image_size,
  File "mobile_net_trainer.py", line 63, in AddImageInput
    mirror=1
  File "/usr/local/lib/python2.7/dist-packages/caffe2/python/brew.py", line 107, in scope_wrapper
    return func(*args, **new_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/caffe2/python/helpers/tools.py", line 12, in image_input
    assert 'is_test' in kwargs, "Argument 'is_test' is required"
AssertionError: Argument 'is_test' is required

I fixed this by adding "is_test" argument to AddImageInput() and "is_test=is_test" to the parameter list of brew.image_input().

Then I added

    is_test=True

to the first call to AddImageInput and

    is_test=False

to the second call to AddImageInput.