PaddleOCR icon indicating copy to clipboard operation
PaddleOCR copied to clipboard

How to use StyleText to generate text image with your own font?

Open goodmight opened this issue 2 years ago • 4 comments

请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem

  • 系统环境/System Environment:win10
  • 版本号/Version:Paddle: PaddleOCR: 问题相关组件/Related components:
  • 运行指令/Command Code: python tools/synth_image.py -c configs/config.yml --style_image examples/style_images/2.jpg --text_corpus 123456 --language art_font
  • 完整报错/Complete Error Message: No Errors but model predict(synth image) gives bad result with art font.

Here is what I've found.

In StyleText/engine/synthesisers.py, 40:

def synth_image(self, corpus, style_input, language="en"):
    corpus_list, text_input_list = self.text_drawer.draw_text(              # <---------- this draw_text work fine with font : **C:\Windows\fonts\complex_.ttf**
        corpus, language, style_input_width=style_input.shape[1])
    synth_result = self.predictor.predict(style_input, text_input_list)  # <----------   this predict which synth the text image with the background fails. It generates Korean text image with English or digits corpus.
    return synth_result

textImage generated in digits. fake_inprogress fake_inprogress2

but synth image is in Korean. fake_text fake_fusion

How to train the downloaded model with new fonts? Thanks! the download url is: https://paddleocr.bj.bcebos.com/dygraph_v2.0/style_text/style_text_models.zip as given in the StyleText/README.md

goodmight avatar Sep 20 '22 11:09 goodmight

Training code is not provided at this stage

an1018 avatar Sep 21 '22 10:09 an1018

@goodmight 你有找到替代方案么?遇到同样问题了

sheltonsuen avatar Nov 04 '22 06:11 sheltonsuen

@goodmight 你有找到替代方案么?遇到同样问题了

Hao dai wo yeshi yong yingwen tiwende ba, ni za zhijie yong zhongwen wen wo (・∀・)

我的替代_(舍弃)方案是發現我不需要這個背景圖片。所以直接用白底寫字(PIL的方法)了。

goodmight avatar Nov 05 '22 12:11 goodmight

好的,多谢,我发现我也得舍弃这个嘞,我准备用 inpatint 的方式,先扣掉然后再写上去新的

sheltonsuen avatar Nov 07 '22 01:11 sheltonsuen

请问是在哪一步骤修改呢

Sencc avatar Mar 07 '24 10:03 Sencc