You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Synthdog to generate some data, I noticed when the character is backslash, the image would not be able to render it properly. Instead, it would render it as a box with a cross inside, such as
Steps to Reproduce
change textbox.py as follows
"""
Donut
Copyright (c) 2022-present NAVER Corp.
MIT License
"""
import numpy as np
from synthtiger import layers
import random
class TextBox:
def __init__(self, config):
self.fill = config.get("fill", [1, 1])
self.charset = """\\"""
def generate(self, size, text,font):
width, height = size
char_layers, chars = [], []
fill = np.random.uniform(self.fill[0], self.fill[1])
width = np.clip(width * fill, height, width)
font = {**font, "size": int(height)}
left, top = 0, 0
for char in text:
if char in "\r\n":
continue
rand = random.uniform(0, 1)
if rand >= 0:
char = random.choice(self.charset)
char_layer = layers.TextLayer(char, **font)
char_scale = height / char_layer.height
char_layer.bbox = [left, top, *(char_layer.size * char_scale)]
if char_layer.right > width:
break
char_layers.append(char_layer)
chars.append(char)
left = char_layer.right
text = "".join(chars).strip()
if len(char_layers) == 0 or len(text) == 0:
return None, None
text_layer = layers.Group(char_layers).merge()
return text_layer, text
Then run something like synthtiger -o ./outputs/SynthDoG_exp -c 50 -w 4 -v template.py SynthDoG config_en.yaml inside ./synthdog
Issue
When using Synthdog to generate some data, I noticed when the character is backslash, the image would not be able to render it properly. Instead, it would render it as a box with a cross inside, such as
![image](https://private-user-images.githubusercontent.com/55818214/243484365-3d35624b-91e8-4e2c-b539-5ab8f7259de4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkwNDQ4MzcsIm5iZiI6MTcxOTA0NDUzNywicGF0aCI6Ii81NTgxODIxNC8yNDM0ODQzNjUtM2QzNTYyNGItOTFlOC00ZTJjLWI1MzktNWFiOGY3MjU5ZGU0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjIyVDA4MjIxN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWMzOGUyMjExNTMzZTUxMmU4OTQwYWJjMDhmNDI5YTkxMTAzNmI1MmMxY2Y0MDk0MzZjYmY5MTM2NWEyMWViOGEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.LlyaiYn0O2Wy2MuoYn-KDDLlhpzx8LSPfw4L7OC7X6Y)
Steps to Reproduce
textbox.py
as followsThen run something like
synthtiger -o ./outputs/SynthDoG_exp -c 50 -w 4 -v template.py SynthDoG config_en.yaml
inside./synthdog
Possible Fix
It took me a while until I came across this
https://github.com/clovaai/synthtiger/blob/c00cc7bfa07f8178009ebaa41b64680b0e392701/synthtiger/layers/text_layer.py#L25
I don't know what's the purpose of this line? Somehow it replaces backslash into some other strange character which some of the fonts have trouble rendering. Commenting it out would resolve the backslash issue.
The text was updated successfully, but these errors were encountered: