KaihuaTang / Scene-Graph-Benchmark.pytorch

A new codebase for popular Scene Graph Generation methods (2020). Visualization & Scene Graph Extraction on custom images/datasets are provided. It's also a PyTorch implementation of paper “Unbiased Scene Graph Generation from Biased Training CVPR 2020”
MIT License
1.03k stars 228 forks source link

KeyError: 'Non-existent config key: TEST.CUSTUM_EVAL' #119

Open folkaholic opened 3 years ago

folkaholic commented 3 years ago

❓ Questions and Help

Thanks for Kaihua's great work! I have a question about testing custumed images. When I ran the code to generate the json file for custumed images, I met a bug. Is something wrong with my configuration or something else? If someone have met and solved the same problem, could you please tell me the possible solution? Thanks!

Here is my error:

Traceback (most recent call last): File "tools/relation_test_net.py", line 119, in main() File "tools/relation_test_net.py", line 62, in main cfg.merge_from_file(args.config_file) File ".../lib/python3.8/site-packages/yacs/config.py", line 213, in merge_from_file self.merge_from_other_cfg(cfg) File ".../lib/python3.8/site-packages/yacs/config.py", line 217, in merge_from_other_cfg _merge_a_into_b(cfg_other, self, self, []) File ".../lib/python3.8/site-packages/yacs/config.py", line 460, in _merge_a_into_b _merge_a_into_b(v, b[k], root, key_list + [k]) File ".../lib/python3.8/site-packages/yacs/config.py", line 473, in _merge_a_into_b raise KeyError("Non-existent config key: {}".format(full_key)) KeyError: 'Non-existent config key: TEST.CUSTUM_EVAL' Traceback (most recent call last): File ".../lib/python3.8/runpy.py", line 193, in _run_module_as_main return _run_code(code, main_globals, None, File ".../lib/python3.8/runpy.py", line 86, in _run_code exec(code, run_globals) File ".../lib/python3.8/site-packages/torch/distributed/launch.py", line 263, in main() File ".../lib/python3.8/site-packages/torch/distributed/launch.py", line 258, in main raise subprocess.CalledProcessError(returncode=process.returncode,

zl535320706 commented 1 year ago

KeyError: Non-existent config key...

我推测,此类问题都是由于作者使用的是自己修改的maskrcnn_benchmark,因为原始的maskrcnn_benchmark主要用于目标检测,不含有关系分类头和属性分类头,所以e2e_relation...等yaml文件中定义的key在原始的maskrcnn_benchmark中都不存在,自然cfg变量中也就不存在这些key,就会在File "tools/relation_test_net.py", line 62, in main cfg.merge_from_file(args.config_file) 中报错。

解决的办法其实很简单,首先是把环境中已有的maskrcnn_benchmark卸载(这个包可能大概率你是通过pip或者conda安装的),保证在执行bash scripts/test.sh 时报错:no module named maskrcnn_benchmark,说明环境中已有的maskrcnn_benchmark已经卸载干净。然后cd到PENET中,执行python setup.py build develop,安装作者修改的maskrcnn_benchmark,最后解决相关的依赖问题(比如from .cv2 import * ImportError: libGL.so.1,执行apt-install libgl1-mesa-dev),cfg.merge_from_file(args.config_file)就过了。

这个问题可能新手会碰到吧(比如我这样的),大佬一般不会遇到这个问题....

Translate by SparkDesk:

ERROR: KeyError: 'Non-existent config key...'

This type of issue is usually caused by the author modifying the maskrcnn_benchmark package, which is originally designed for object detection and does not contain relation and attribute classification heads. Therefore, the keys defined in the YAML files such as e2e_relation... do not exist in the original maskrcnn_benchmark package, and thus the corresponding keys in the cfg variable also do not exist, leading to the error in File "tools/relation_test_net.py", line 62, in main cfg.merge_from_file(args.config_file)

The solution is actually quite simple. First, uninstall the existing maskrcnn_benchmark package (which you probably installed through pip or conda), to ensure that when executing bash scripts/test.sh, it reports an error: no module named maskrcnn_benchmark, indicating that the existing maskrcnn_benchmark package has been uninstalled cleanly. Then cd to PENET and execute python setup.py build develop to install the modified maskrcnn_benchmark package developed by the author, and finally resolve any related dependencies (for example, from .cv2 import * ImportError: libGL.so.1, execute apt-install libgl1-mesa-dev). cfg.merge_from_file(args.config_file) will be passed.

This problem may be encountered by beginners (such as me), while experts generally won't encounter this type of issue.