neural-style-pt icon indicating copy to clipboard operation
neural-style-pt copied to clipboard

Add verbose option

Open momo-the-monster opened this issue 6 years ago • 4 comments

Thanks for all your work on this project! I'm using it for Colab notebook experiments and found that it printed more lines to the console than I would like, so I added this -verbose flag in for myself so I could set it to 0 when I don't need as many updates.

momo-the-monster avatar Jul 31 '19 22:07 momo-the-monster

Hi @ProGamerGov! Just fixed the merged conflicts introduced with the latest and greatest from the master branch so I'm bumping this up for visibility. The -verbose flag is super helpful when running in Colab notebooks, especially as I have this in front of a group of designers at our company right now. Let me know if you have a thought on another way you'd like to see this implemented. Thanks!

momo-the-monster avatar Nov 15 '19 19:11 momo-the-monster

@momo-the-monster Nice work!

I'm not sure about using a ton of if statements to block all the print statements. It's fine to use that once in CaffeLoader to block printing the conv layers, but it looks a bit ugly to use it for every print statement.

I guess one could use: sys.stdout = open(os.devnull, 'w') to completely block printing until some point, but reenabling printing could be tricky.

Also, the verbose parameter doesn't need to use integers. It can just be a boolean flag.

ProGamerGov avatar Nov 15 '19 21:11 ProGamerGov

Hm, agreed. I don't work in Python much -what do you think about using the built-in logging library (or a third-party one like loguru) where the user could configure what level they want to print? That way I could easily supress anything error or below.

momo-the-monster avatar Nov 16 '19 08:11 momo-the-monster

@ProGamerGov - had another go at this, much simpler this time around.

I just added a -log_level parameter and switched all the print() commands to logging.info() commands.

The log level is INFO by default, so everything shows up. If you pass -log_level 30 or higher, then you get no outputs. Future-compatible because any new code can just log using the appropriate level, the param supports all Python log levels.

It looks like you've got a couple of branches in various states so I made this off the latest master. Happy to redo it off another branch if that makes it more likely to get merged.

momo-the-monster avatar Jan 13 '20 23:01 momo-the-monster