feat: randomize generator
Browse files- font_dataset/background.py +2 -2
- font_dataset/text.py +1 -4
font_dataset/background.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import os
|
|
|
|
| 2 |
from PIL import Image
|
| 3 |
|
| 4 |
|
|
@@ -10,5 +11,4 @@ def background_image_generator(path="./dataset/pixivimages"):
|
|
| 10 |
image_list = [os.path.join(path, image) for image in image_list]
|
| 11 |
|
| 12 |
while True:
|
| 13 |
-
|
| 14 |
-
yield image
|
|
|
|
| 1 |
import os
|
| 2 |
+
import random
|
| 3 |
from PIL import Image
|
| 4 |
|
| 5 |
|
|
|
|
| 11 |
image_list = [os.path.join(path, image) for image in image_list]
|
| 12 |
|
| 13 |
while True:
|
| 14 |
+
yield random.choice(image_list)
|
|
|
font_dataset/text.py
CHANGED
|
@@ -77,11 +77,9 @@ class JapaneseUtaNetCorpusGenerator(CommonCorpusGenerator):
|
|
| 77 |
self.conn = sqlite3.connect("lyrics_corpus/cache/uta-net.db")
|
| 78 |
self.cur = self.conn.cursor()
|
| 79 |
|
| 80 |
-
i = 0
|
| 81 |
-
|
| 82 |
while True:
|
| 83 |
self.cur.execute(
|
| 84 |
-
|
| 85 |
)
|
| 86 |
row = self.cur.fetchone()
|
| 87 |
if row is not None:
|
|
@@ -92,7 +90,6 @@ class JapaneseUtaNetCorpusGenerator(CommonCorpusGenerator):
|
|
| 92 |
continue
|
| 93 |
else:
|
| 94 |
return
|
| 95 |
-
i += 1
|
| 96 |
|
| 97 |
def _random_place_holder(self, font: DSFont) -> str:
|
| 98 |
r = random.randint(1, 3)
|
|
|
|
| 77 |
self.conn = sqlite3.connect("lyrics_corpus/cache/uta-net.db")
|
| 78 |
self.cur = self.conn.cursor()
|
| 79 |
|
|
|
|
|
|
|
| 80 |
while True:
|
| 81 |
self.cur.execute(
|
| 82 |
+
"SELECT lyrics FROM lyrics WHERE song_id IN (SELECT song_id FROM lyrics ORDER BY RANDOM() LIMIT 1)"
|
| 83 |
)
|
| 84 |
row = self.cur.fetchone()
|
| 85 |
if row is not None:
|
|
|
|
| 90 |
continue
|
| 91 |
else:
|
| 92 |
return
|
|
|
|
| 93 |
|
| 94 |
def _random_place_holder(self, font: DSFont) -> str:
|
| 95 |
r = random.randint(1, 3)
|