deepjavalibrary / djl

An Engine-Agnostic Deep Learning Framework in Java
https://djl.ai
Apache License 2.0
4.13k stars 656 forks source link

About the progress bar output stream #2180

Closed WabbyWabbo closed 1 year ago

WabbyWabbo commented 1 year ago

Description

When i was loading model, i got Loading: 100% |========================================| in console. I found that is from ai.djl.training.util.ProgressBar which has System.out.println. Can this be replaced by logger in the future? Thanks.

frankfliu commented 1 year ago

ai.djl.training.util.ProgressBar is designed for console application. It doesn't work well with log file. You can redirect the console out put to a file, and you can the progress looks ugly in the file.

In real world, you don't need to pass Progress to Criteria class, it's optional. You can also create your own implementation of Progress if customize for your own logging purpose.

WabbyWabbo commented 1 year ago

ai.djl.training.util.ProgressBar is designed for console application. It doesn't work well with log file. You can redirect the console out put to a file, and you can the progress looks ugly in the file.

In real world, you don't need to pass Progress to Criteria class, it's optional. You can also create your own implementation of Progress if customize for your own logging purpose.

Thanks frank. That solved my problem. My another question is that How can i get these output when my app is packaged into a fat-jar file? image

My application runs well in InteliJ idea with some red text output in idea's Run Console , but when it's packaged to a jar file with maven shade plugin (not assembly plugin, i've into #1428 once ). When i run my packaged fat-jar, it just get stucked somewhere forever without any output, which makes it hard for me to debug. I think there must be something wrong in package phrase, but i cannot see the full debug output. I've been here for about a week without any effective progress. Do you have any idea? Thanks again.

frankfliu commented 1 year ago

Your console output comes from paddlepaddle native code. Not from java logger.

You need use a proper logging system (e.g. log4j2, logback etc.) to enable java logging.

For how to distribute your application, you can take a our demo: https://github.com/deepjavalibrary/djl-demo/tree/master/development/fatjar

frankfliu commented 1 year ago

Feel free to re-open the issue if you still have question.