简体   繁体   中英

Setting GLOG_minloglevel=1 to prevent output in shell from Caffe

I'm using Caffe, which is printing a lot of output to the shell when loading the neural net.
I'd like to suppress that output, which supposedly can be done by setting GLOG_minloglevel=1 when running the Python script. I've tried doing that using the following code, but I still get all the output from loading the net. How do I suppress the output correctly?

os.environ["GLOG_minloglevel"] = "1"
net = caffe.Net(model_file, pretrained, caffe.TEST)
os.environ["GLOG_minloglevel"] = "0"

To supress the output level you need to increase the loglevel to at least 2

 os.environ['GLOG_minloglevel'] = '2' 

The levels are

0 - debug
1 - info (still a LOT of outputs)
2 - warnings
3 - errors


Update:
Since this flag is global to caffe , it must be set prior to importing of caffe package (as pointed out by jbum ). Once the flag is set and caffe is imported the behavior of the GLOG tool cannot be changed.

我能够让Shai的解决方案工作,但只能调用之前在Python中执行该行

import caffe

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM