fix: use typing module to fix dep for py 3.6
Browse files- font_dataset/font.py +3 -1
- font_dataset/fontlabel.py +4 -3
- font_dataset/layout.py +3 -1
font_dataset/font.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
import yaml
|
2 |
import os
|
|
|
|
|
3 |
|
4 |
from .utils import get_files
|
5 |
|
@@ -13,7 +15,7 @@ class DSFont:
|
|
13 |
self.language = language
|
14 |
|
15 |
|
16 |
-
def load_fonts(config_path="configs/font.yml") ->
|
17 |
with open(config_path, "r", encoding="utf-8") as f:
|
18 |
config = yaml.safe_load(f)
|
19 |
|
|
|
1 |
import yaml
|
2 |
import os
|
3 |
+
from typing import List
|
4 |
+
|
5 |
|
6 |
from .utils import get_files
|
7 |
|
|
|
15 |
self.language = language
|
16 |
|
17 |
|
18 |
+
def load_fonts(config_path="configs/font.yml") -> List[DSFont]:
|
19 |
with open(config_path, "r", encoding="utf-8") as f:
|
20 |
config = yaml.safe_load(f)
|
21 |
|
font_dataset/fontlabel.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
__all__ = ["FontLabel"]
|
2 |
|
|
|
3 |
from .font import DSFont
|
4 |
|
5 |
|
@@ -26,14 +27,14 @@ class FontLabel:
|
|
26 |
image_height: int,
|
27 |
text: str,
|
28 |
font: DSFont,
|
29 |
-
text_color:
|
30 |
text_size: int,
|
31 |
text_direction: str,
|
32 |
stroke_width: int,
|
33 |
-
stroke_color:
|
34 |
line_spacing: int,
|
35 |
language: str,
|
36 |
-
bbox:
|
37 |
angle: int,
|
38 |
):
|
39 |
self.image_width = image_width
|
|
|
1 |
__all__ = ["FontLabel"]
|
2 |
|
3 |
+
from typing import Tuple
|
4 |
from .font import DSFont
|
5 |
|
6 |
|
|
|
27 |
image_height: int,
|
28 |
text: str,
|
29 |
font: DSFont,
|
30 |
+
text_color: Tuple[int, int, int],
|
31 |
text_size: int,
|
32 |
text_direction: str,
|
33 |
stroke_width: int,
|
34 |
+
stroke_color: Tuple[int, int, int],
|
35 |
line_spacing: int,
|
36 |
language: str,
|
37 |
+
bbox: Tuple[int, int, int, int],
|
38 |
angle: int,
|
39 |
):
|
40 |
self.image_width = image_width
|
font_dataset/layout.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
__all__ = ["generate_font_image"]
|
2 |
|
3 |
|
@@ -237,7 +239,7 @@ def RGB2RGBA(color):
|
|
237 |
|
238 |
def generate_font_image(
|
239 |
img_path: str, font: DSFont, corpus_manager: CorpusGeneratorManager
|
240 |
-
) ->
|
241 |
im = Image.open(img_path)
|
242 |
# crop image
|
243 |
width, height = im.size
|
|
|
1 |
+
from typing import Tuple
|
2 |
+
|
3 |
__all__ = ["generate_font_image"]
|
4 |
|
5 |
|
|
|
239 |
|
240 |
def generate_font_image(
|
241 |
img_path: str, font: DSFont, corpus_manager: CorpusGeneratorManager
|
242 |
+
) -> Tuple[Image.Image, FontLabel]:
|
243 |
im = Image.open(img_path)
|
244 |
# crop image
|
245 |
width, height = im.size
|