Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output text masks, upgrade dependencies, improved code and docs #155

Open
wants to merge 11 commits into
base: python3
Choose a base branch
from

Conversation

sslavian812
Copy link

@sslavian812 sslavian812 commented May 5, 2019

Hi there!

In my research, I needed to use your project to generate some images with texts along with masks, labels and bounding boxes.
I added some new features to it, and here is my PR:

  • made this code compatible with mac OS (it was impossible to satisfy dependencies, a lot of problems with pyplot and others)
  • removed deprecated api calls: https://matplotlib.org/api/_as_gen/matplotlib.pyplot.hold.html
    pyplot.hold(True) - works by default since version 3.0 (and the method is removed), scipy.misc.imsave - replaced with recommended imageio.imwrite)
  • updated requirements.txt
  • improved code formatting (used auto-formatting tool)
  • improved and added more of documentation. Used docstrings style by Google. See this for different formats examples https://stackoverflow.com/a/24385103/2877029
  • implemented a new feature: with --output-masks flag users can obtain text masks used to place text to the image (see "_mask.png" files), and bounding boxes of each word with a label (see "_bb.txt" files).
    Run with this flag and see the content of "./masks/" folder for more examples
  • moved output visualization (--viz flag) out of renderer - no need to propagate this flag to renderer logic:
    Following the single responsibility principle: renderer should render, a generator should generate (and, optionally, display result for users)
  • added debug logs and --debug flag, which enables more logs to be printed.
    Tested combinations "--viz --debug" "--viz --output-masks", "--viz --output-masks --debug" "--output-masks --debug".

Let's work together on merging this contribution to your project.

Btw, I'd very much encourage you to make it python3 by default.

@ankush-me
Copy link
Owner

@sslavian812 : thank you for the pull request. I will review it in a few days and get back to you!

@sslavian812
Copy link
Author

Hi, do you have some news about this pr?

@sslavian812
Copy link
Author

Hi @ankush-me
Did you have some time to take a look at this PR?

@sslavian812
Copy link
Author

Hi @ankush-me
Did you have some time to look into this PR?

Copy link
Owner

@ankush-me ankush-me left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if all of these packages are required, eg. sqlparse, tornado, kiwisolver etc. Can you review / clean these up?

@@ -95,9 +117,12 @@ def main(viz=False):
NUM_IMG = N
start_idx, end_idx = 0, min(NUM_IMG, N)

RV3 = RendererV3(DATA_PATH, max_time=SECS_PER_IMG)
renderer = RendererV3(DATA_PATH, max_time=SECS_PER_IMG)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there seem to be two data_paths -- data_path and DATA_PATH?

gen.py Outdated
args = parser.parse_args()
main(args.viz)
main(viz=args.viz, output_masks=args.output_masks)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if viz is set to True, the app crashes.

@ankush-me
Copy link
Owner

@sslavian812 Thanks for this pull request. I tried to test it out but kept running into issues. I've highlighted some of these in the comments above. Will review later with (hopefully) more time at hand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants