alkzar90 commited on
Commit
64e25d3
1 Parent(s): d584a00

Update cell_benchmark.py

Browse files
Files changed (1) hide show
  1. cell_benchmark.py +11 -15
cell_benchmark.py CHANGED
@@ -18,7 +18,9 @@ _SPLIT_URLS = {
18
  "train": _URL_BASE + "train.zip",
19
  "val": _URL_BASE + "val.zip",
20
  "test": _URL_BASE + "test.zip",
21
- "masks": _URL_BASE + "masks.zip",
 
 
22
  }
23
 
24
 
@@ -41,16 +43,13 @@ class Cellsegmentation(datasets.GeneratorBasedBuilder):
41
 
42
 
43
  def _split_generators(self, dl_manager):
44
- data_files = dl_manager.download_and_extract(_SPLIT_URLS)
45
- #masks_dir = [os.path.dirname(path) for i, path in enumerate(dl_manager.iter_files([data_files["masks"]])) if i < 1][0]
46
- masks_dir = dl_manager.iter_files([data_files["masks"]])
47
-
48
  splits = [
49
  datasets.SplitGenerator(
50
  name=datasets.Split.TRAIN,
51
  gen_kwargs={
52
  "files" : dl_manager.iter_files([data_files["train"]]),
53
- "masks_dir": masks_dir,
54
  "split": "training",
55
  },
56
  ),
@@ -58,7 +57,7 @@ class Cellsegmentation(datasets.GeneratorBasedBuilder):
58
  name=datasets.Split.VALIDATION,
59
  gen_kwargs={
60
  "files" : dl_manager.iter_files([data_files["val"]]),
61
- "masks_dir": masks_dir,
62
  "split": "validation",
63
  },
64
  ),
@@ -66,7 +65,7 @@ class Cellsegmentation(datasets.GeneratorBasedBuilder):
66
  name=datasets.Split.TEST,
67
  gen_kwargs={
68
  "files" : dl_manager.iter_files([data_files["test"]]),
69
- "masks_dir": masks_dir,
70
  "split": "test",
71
  }
72
  )
@@ -74,14 +73,11 @@ class Cellsegmentation(datasets.GeneratorBasedBuilder):
74
  return splits
75
 
76
 
77
- def _generate_examples(self, files, masks_dir, split):
78
- masks_dir = [os.path.dirname(path) for i, path in enumerate(masks_dir) if i < 1][0]
79
- for i, path in enumerate(files):
80
- file_name = "/mask_" + os.path.basename(path).replace("jpg", "png")
81
  yield i, {
82
- "image": path,
83
- #"masks": masks_dir + "/mask_" + file_name.replace("jpg", "png"),
84
- "masks": masks_dir + file_name,
85
  "path": path,
86
  }
87
 
 
18
  "train": _URL_BASE + "train.zip",
19
  "val": _URL_BASE + "val.zip",
20
  "test": _URL_BASE + "test.zip",
21
+ "masks_train": _URL_BASE + "masks/train.zip",
22
+ "masks_val": _URL_BASE + "masks/val.zip",
23
+ "masks_test": _URL_BASE + "masks/test.zip",
24
  }
25
 
26
 
 
43
 
44
 
45
  def _split_generators(self, dl_manager):
46
+ data_files = dl_manager.download_and_extract(_SPLIT_URLS)
 
 
 
47
  splits = [
48
  datasets.SplitGenerator(
49
  name=datasets.Split.TRAIN,
50
  gen_kwargs={
51
  "files" : dl_manager.iter_files([data_files["train"]]),
52
+ "masks": dl_manager.iter_files([data_files["masks_train"]]),
53
  "split": "training",
54
  },
55
  ),
 
57
  name=datasets.Split.VALIDATION,
58
  gen_kwargs={
59
  "files" : dl_manager.iter_files([data_files["val"]]),
60
+ "masks": dl_manager.iter_files([data_files["masks_val"]]),
61
  "split": "validation",
62
  },
63
  ),
 
65
  name=datasets.Split.TEST,
66
  gen_kwargs={
67
  "files" : dl_manager.iter_files([data_files["test"]]),
68
+ "masks": dl_manager.iter_files([data_files["masks_test"]]),
69
  "split": "test",
70
  }
71
  )
 
73
  return splits
74
 
75
 
76
+ def _generate_examples(self, files, masks, split):
77
+ for i, path in enumerate(zip(files, masks)):
 
 
78
  yield i, {
79
+ "image": path[0],
80
+ "masks": path[1],
 
81
  "path": path,
82
  }
83