salesforce / densecap

BSD 3-Clause "New" or "Revised" License
188 stars 61 forks source link

ImportError: No module named 'data' #33

Closed kkjh0723 closed 4 years ago

kkjh0723 commented 4 years ago

When I run following command,

python scripts/test.py --cfgs_file cfgs/yc2_mod.yml --densecap_eval_file ./tools/densevid_eval/evaluate.py --batch_size 1 --start_from ./checkpoint/yc2-2L-gt-mask/model_epoch_19.t7 --id yc2-2L-gt-mask-19 --val_data_folder validation --cuda | tee log/eval-yc2-2L-gt-mask-19

I got the following error,

Traceback (most recent call last):
  File "scripts/test.py", line 24, in <module>
    from data.anet_test_dataset import ANetTestDataset, anet_test_collate_fn
ImportError: No module named 'data'

It seems that the issue related to the python path. When I copy the test.py to the root directory, then it runs without any error. How to make it run without copying the file to the root directory?

LuoweiZhou commented 4 years ago

@kkjh0723 You could try exporting the path to env variable PYTHONPATH: export PYTHONPATH=$PYTHONPATH:[PATH TO YOUR DIR]/densecap Would be helpful to add that for the submodule coco-caption as well: export PYTHONPATH=$PYTHONPATH:[PATH TO YOUR DIR]/densecap/tools/densevid_eval/coco-caption

AnukritiSinghh commented 4 years ago

I get the same error for train.py and I dont know what to do. I am new to this. Should write like this when I run - "--export PYTHONPATH=...." ?

LuoweiZhou commented 4 years ago

No, you are setting environment variables. So, you need to run these before your python command.

AnukritiSinghh commented 4 years ago

Thank you. It worked!

AnukritiSinghh commented 4 years ago

I have one other question, do I need to write the $id in " --checkpoint_path ./checkpoint/$id" ? Because I am getting this error - train.py: error: unrecognized arguments: --checkpoint_path ./checkpoint/ --cuda