bastienp commited on
Commit
248ace0
1 Parent(s): 163fb3d

feat: change bbox format

Browse files
Files changed (1) hide show
  1. visible-watermark-pita.py +13 -20
visible-watermark-pita.py CHANGED
@@ -15,7 +15,7 @@ _VERSION = datasets.Version("1.0.0")
15
  class WatermarkPitaConfig(datasets.BuilderConfig):
16
  """Builder Config for Food-101"""
17
 
18
- def __init__(self, repository, urls, categories, **kwargs):
19
  """BuilderConfig for Food-101.
20
 
21
  Args:
@@ -28,7 +28,6 @@ class WatermarkPitaConfig(datasets.BuilderConfig):
28
  _VERSION = datasets.Version("1.0.0")
29
 
30
  super(WatermarkPitaConfig, self).__init__(version=_VERSION, **kwargs)
31
- self.repository = repository
32
  self.urls = urls
33
  self.categories = categories
34
 
@@ -39,10 +38,19 @@ class WatermarkPita(datasets.GeneratorBasedBuilder):
39
  BUILDER_CONFIGS = [
40
  WatermarkPitaConfig(
41
  name="text",
42
- repository="data",
43
  urls={"train": "data/text/train.zip", "valid": "data/text/valid.zip"},
44
  categories=["text"],
45
- )
 
 
 
 
 
 
 
 
 
 
46
  ]
47
 
48
  _DEFAULT_CONFIG_NAME = "text"
@@ -66,7 +74,6 @@ class WatermarkPita(datasets.GeneratorBasedBuilder):
66
  )
67
 
68
  def _split_generators(self, dl_manager):
69
- print(self.config.urls)
70
  data_dir = dl_manager.download_and_extract(self.config.urls)
71
 
72
  return [
@@ -86,23 +93,9 @@ class WatermarkPita(datasets.GeneratorBasedBuilder):
86
 
87
  image_paths = sorted(glob(image_dir + "/*.jpg"))
88
  label_paths = sorted(glob(label_dir + "/*.json"))
89
-
90
 
91
  for idx, (image_path, label_path) in enumerate(zip(image_paths, label_paths)):
92
  with open(label_path, "r") as f:
93
  bbox = json.load(f)
94
 
95
- objects = []
96
- objects.append(
97
- {
98
- "label": bbox["label"],
99
- "bbox": [
100
- bbox["x"],
101
- bbox["y"],
102
- bbox["width"],
103
- bbox["height"],
104
- ],
105
- }
106
- )
107
-
108
- yield idx, {"image": image_path, "objects": objects}
 
15
  class WatermarkPitaConfig(datasets.BuilderConfig):
16
  """Builder Config for Food-101"""
17
 
18
+ def __init__(self, urls, categories, **kwargs):
19
  """BuilderConfig for Food-101.
20
 
21
  Args:
 
28
  _VERSION = datasets.Version("1.0.0")
29
 
30
  super(WatermarkPitaConfig, self).__init__(version=_VERSION, **kwargs)
 
31
  self.urls = urls
32
  self.categories = categories
33
 
 
38
  BUILDER_CONFIGS = [
39
  WatermarkPitaConfig(
40
  name="text",
 
41
  urls={"train": "data/text/train.zip", "valid": "data/text/valid.zip"},
42
  categories=["text"],
43
+ ),
44
+ WatermarkPitaConfig(
45
+ name="logo",
46
+ urls={"train": "data/logo/train.zip", "valid": "data/logo/valid.zip"},
47
+ categories=["logo"],
48
+ ),
49
+ WatermarkPitaConfig(
50
+ name="mixed",
51
+ urls={"train": "data/mixed/train.zip", "valid": "data/mixed/valid.zip"},
52
+ categories=["logo", "text"],
53
+ ),
54
  ]
55
 
56
  _DEFAULT_CONFIG_NAME = "text"
 
74
  )
75
 
76
  def _split_generators(self, dl_manager):
 
77
  data_dir = dl_manager.download_and_extract(self.config.urls)
78
 
79
  return [
 
93
 
94
  image_paths = sorted(glob(image_dir + "/*.jpg"))
95
  label_paths = sorted(glob(label_dir + "/*.json"))
 
96
 
97
  for idx, (image_path, label_path) in enumerate(zip(image_paths, label_paths)):
98
  with open(label_path, "r") as f:
99
  bbox = json.load(f)
100
 
101
+ yield idx, {"image": image_path, "objects": bbox}