Layout-Parser / layout-parser

A Unified Toolkit for Deep Learning Based Document Image Analysis
https://layout-parser.github.io/
Apache License 2.0
4.78k stars 459 forks source link

"lp.draw_box()" is not able to displays the result in .py file #47

Open vilktor370 opened 3 years ago

vilktor370 commented 3 years ago

Hi everyone! Thanks for developing this package. It was quite impressive to see the work you guys have achieved. I have a lot of fun when I was messed around with it.

However, would it be possible for the draw_box function to be working in a normal .py file? I was originally writing all the code in a normal python file but, the draw_box function just couldn't display the result to me somehow. I am on Ubuntu 20.04 and Python 3.8 is the version I am using. Then, I switched to the Jupyter Notebook extension in Visual Studio Code. Everything was up and running fine. I noticed in your examples, you guys are using the .ipynb file to show the example as well. I don't know it's a bug on my end or it just couldn't display the result in a normal python file. I don't have a strong reason why we should use the .py file instead of the .pynb. I just noticed a lot of other packages support both, so I guess it would be good if this one also supports them.

Thanks!

lolipopshock commented 3 years ago

Thanks! The command will return an PIL image object, and you could try to use the .show command to have it displayed: lp.draw_box(xx).show(). It's definitely not the most elegant solution - let me figure out a better one and incorporate it into the library.

You might also want to check more about this issue here.

vilktor370 commented 3 years ago

I will try that solution later today. I didn't realize you guys are using PIL for image processing. Would it be possible for you guys to transfer the PIL image object into an actual image (like the ones that could be displayed using OpenCV or matplotlib)? I don't know the details to achieve this but I think this could be a valid solution. And then whenever we call the draw_box function. It would return the actual image. This way users can save the image for later or do other image processing if they need.