Spaces:
Runtime error
Runtime error
Niv Sardi
commited on
Commit
·
b658b84
1
Parent(s):
6ef300c
augmenter: import main csv and convert bco to id so it's all ready for yolo
Browse files- python/augment.py +8 -1
python/augment.py
CHANGED
@@ -2,6 +2,7 @@ import os
|
|
2 |
import time
|
3 |
import math
|
4 |
import random
|
|
|
5 |
|
6 |
from io import BytesIO
|
7 |
import numpy as np
|
@@ -15,6 +16,7 @@ import imgaug as ia
|
|
15 |
from imgaug import augmenters as iaa
|
16 |
from imgaug.augmentables.batches import UnnormalizedBatch
|
17 |
|
|
|
18 |
from common import defaults, mkdir
|
19 |
import imtool
|
20 |
import pipelines
|
@@ -27,6 +29,11 @@ logo_images = []
|
|
27 |
logo_alphas = []
|
28 |
logo_labels = {}
|
29 |
|
|
|
|
|
|
|
|
|
|
|
30 |
background_images = [d for d in os.scandir(defaults.IMAGES_PATH)]
|
31 |
|
32 |
stats = {
|
@@ -46,7 +53,7 @@ for d in os.scandir(defaults.LOGOS_DATA_PATH):
|
|
46 |
else:
|
47 |
png = svg2png(url=d.path)
|
48 |
img = cv2.imdecode(np.asarray(bytearray(png), dtype=np.uint8), cv2.IMREAD_UNCHANGED)
|
49 |
-
label = d.name.split('.')[0]
|
50 |
|
51 |
(h, w, c) = img.shape
|
52 |
if c == 3:
|
|
|
2 |
import time
|
3 |
import math
|
4 |
import random
|
5 |
+
import csv
|
6 |
|
7 |
from io import BytesIO
|
8 |
import numpy as np
|
|
|
16 |
from imgaug import augmenters as iaa
|
17 |
from imgaug.augmentables.batches import UnnormalizedBatch
|
18 |
|
19 |
+
from entity import Entity
|
20 |
from common import defaults, mkdir
|
21 |
import imtool
|
22 |
import pipelines
|
|
|
29 |
logo_alphas = []
|
30 |
logo_labels = {}
|
31 |
|
32 |
+
db = {}
|
33 |
+
with open(defaults.MAIN_CSV_PATH, 'r') as f:
|
34 |
+
reader = csv.DictReader(f)
|
35 |
+
db = {e.bco: e for e in [Entity.from_dict(d) for d in reader]}
|
36 |
+
|
37 |
background_images = [d for d in os.scandir(defaults.IMAGES_PATH)]
|
38 |
|
39 |
stats = {
|
|
|
53 |
else:
|
54 |
png = svg2png(url=d.path)
|
55 |
img = cv2.imdecode(np.asarray(bytearray(png), dtype=np.uint8), cv2.IMREAD_UNCHANGED)
|
56 |
+
label = db[d.name.split('.')[0]].id
|
57 |
|
58 |
(h, w, c) = img.shape
|
59 |
if c == 3:
|