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

This algorithm frequently fits character into narrow space ...But I want to add multi lines into broad space #47

Closed
JarveeLee opened this issue Jun 6, 2017 · 15 comments

Comments

@JarveeLee
Copy link

No description provided.

@JarveeLee JarveeLee changed the title This algorithm always fit character into narrow space for one sentence..But I want to This algorithm always fit character into narrow space for one sentence..But I want to add multi lines into broad space Jun 6, 2017
@JarveeLee
Copy link
Author

JarveeLee commented Jun 6, 2017

Like this pic,it will place some chinese character around the narrow edge,but I want to add to the broad white space.This situation frequently happens.
figure_1-2

@JarveeLee JarveeLee changed the title This algorithm always fit character into narrow space for one sentence..But I want to add multi lines into broad space This algorithm somtime fits character into narrow space ...But I want to add multi lines into broad space Jun 6, 2017
@JarveeLee JarveeLee changed the title This algorithm somtime fits character into narrow space ...But I want to add multi lines into broad space This algorithm frequently fits character into narrow space ...But I want to add multi lines into broad space Jun 6, 2017
@JarveeLee
Copy link
Author

figure_2
sometime like this , I think it is good but this situation seldom happens.

@JarveeLee
Copy link
Author

JarveeLee commented Jun 6, 2017

I don't know how to solve this problem....I guess I should change something in text_util.py in line 118
def render_multiline(self,font,text):

But don't know exactly what to do

@JarveeLee
Copy link
Author

figure_3
Maybe it is the problem about depth prediction?

@ankush-me
Copy link
Owner

@JarveeLee : The segmentation regions are randomly selected for placing text (check here). If you remove this, and instead go through the regions in sequence, the regions should be ordered in decreasing order of their areas -- so then the largest region (as found in the segmentation step), should be selected first for placing text.

Next, regarding rendering multiple lines:
You can change this line, so that text_type is always PARA, which should select multiple lines containing multiple words, based on the dimensions of the segmentation region and the font-size.

@JarveeLee
Copy link
Author

Ah ha your solution works pretty nice!Thanks~
After your suggestion averagely it just takes me 6 seconds to select and place text on 1 image with better appearance ! It was bad and took 60 seconds per image yesterday.....

@clscy
Copy link

clscy commented Jun 7, 2017

Hi, @JarveeLee , I want to generate Chinese scene images through SynthText, I have generated char_freq.cp and font_px2pt.cp based on newsgroup.txt, but it comes somes mistakes.

Traceback (most recent call last):
File "/home/chengls/data/SynthText_06.05/synthgen.py", line 661, in render_text
regions['homography_inv'][ireg])
File "/home/chengls/data/SynthText_06.05/synthgen.py", line 501, in place_text
render_res = self.text_renderer.render_sample(font,collision_mask)
File "/home/chengls/data/SynthText_06.05/text_utils.py", line 366, in render_sample
text = self.text_source.sample(nline,nchar,text_type)
File "/home/chengls/data/SynthText_06.05/text_utils.py", line 606, in sample
return self.fdictkind
File "/home/chengls/data/SynthText_06.05/text_utils.py", line 652, in sample_para
lines = self.get_lines(nline, nword, nchar_max, f=0.35)
File "/home/chengls/data/SynthText_06.05/text_utils.py", line 584, in get_lines
lines = h_lines(niter=100)
File "/home/chengls/data/SynthText_06.05/text_utils.py", line 576, in h_lines
line_start = np.random.choice(len(self.txt)-nline)
File "mtrand.pyx", line 1391, in mtrand.RandomState.choice (numpy/random/mtrand/mtrand.c:14900)
ValueError: a must be greater than 0

So could you tell how to generate Chinese scene images in details? Thank you.

@JarveeLee
Copy link
Author

JarveeLee commented Jun 7, 2017

@clscy generate own font_px2pt.cp by adding more chinese fonts which end with .tff,and run invert_font_size.py . And update char_freq.cp based on newsgroup.txt. And you should fix all chinese utf-8 coding problem both in OS and python...

@ankush-me
Copy link
Owner

@JarveeLee is it possible for you to share your code / data with the changes you made for generating Chinese text? It would be very useful for a lot of users. Thanks!

@JarveeLee
Copy link
Author

@ankush-me I can email to you my code next week when go back to company.

@yash0307
Copy link

yash0307 commented Jun 9, 2017

@JarveeLee, would it be possible for you to share code and data with me ? It will be of great help for my ongoing project.

@ankush-me
Copy link
Owner

ankush-me commented Jun 9, 2017

@JarveeLee : Is it possible to share it openly, e.g. on GitHub?

@JarveeLee
Copy link
Author

@ankush-me I will do this ....Busy with final exam these days...

@JarveeLee
Copy link
Author

@ankush-me
Copy link
Owner

@JarveeLee Thanks a lot!

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

No branches or pull requests

4 participants