stumbledparams commited on
Commit
1f360ac
·
verified ·
1 Parent(s): 7f29408

Delete Micro-OD.py

Browse files
Files changed (1) hide show
  1. Micro-OD.py +0 -120
Micro-OD.py DELETED
@@ -1,120 +0,0 @@
1
- """Micro-OD: A few-shot microscopy object detection benchmark."""
2
-
3
- import json
4
- import os
5
-
6
- import datasets
7
-
8
- _DESCRIPTION = """\
9
- Micro-OD is a few-shot microscopy object detection benchmark spanning four
10
- biological imaging domains: BBBC (malaria parasite detection), BCCD (blood
11
- cell counting), LIVECell (RatC6 live-cell imaging), and NIH-3T3 (mouse
12
- fibroblast imaging).
13
-
14
- Two splits are provided:
15
- - example: 10 images per sub-dataset (40 total) — the few-shot support set.
16
- - test: 53 images per sub-dataset (212 total) — the evaluation query set.
17
- """
18
-
19
- # Sorted alphabetically; used as ClassLabel names.
20
- ALL_CLASSES = [
21
- "Gametocyte Cells",
22
- "Platelets",
23
- "Polygonal Cells",
24
- "Red Blood Cells",
25
- "Ring Cells",
26
- "Round Cells",
27
- "Schizont Cells",
28
- "Spindle Cells",
29
- "Trophozoite Cells",
30
- "White Blood Cells",
31
- ]
32
-
33
- SUBDATASETS = ["BBBC", "BCCD", "LIVECell", "NIH-3T3"]
34
-
35
-
36
- class MicroOD(datasets.GeneratorBasedBuilder):
37
- """Micro-OD dataset loader."""
38
-
39
- VERSION = datasets.Version("1.0.0")
40
-
41
- def _info(self):
42
- return datasets.DatasetInfo(
43
- description=_DESCRIPTION,
44
- features=datasets.Features(
45
- {
46
- "image": datasets.Image(),
47
- "image_id": datasets.Value("string"),
48
- "subdataset": datasets.Value("string"),
49
- "objects": datasets.Sequence(
50
- feature={
51
- # COCO format: [x_min, y_min, width, height]
52
- "bbox": datasets.Sequence(
53
- datasets.Value("float32"), length=4
54
- ),
55
- "label": datasets.ClassLabel(names=ALL_CLASSES),
56
- "category": datasets.Value("string"),
57
- }
58
- ),
59
- }
60
- ),
61
- )
62
-
63
- def _split_generators(self, dl_manager):
64
- data_dir = os.path.dirname(os.path.abspath(__file__))
65
- return [
66
- datasets.SplitGenerator(
67
- name=datasets.splits.NamedSplit("example"),
68
- gen_kwargs={"split_path": os.path.join(data_dir, "example")},
69
- ),
70
- datasets.SplitGenerator(
71
- name=datasets.Split.TEST,
72
- gen_kwargs={"split_path": os.path.join(data_dir, "test")},
73
- ),
74
- ]
75
-
76
- def _generate_examples(self, split_path):
77
- idx = 0
78
- for subdataset in SUBDATASETS:
79
- annotation_path = os.path.join(
80
- split_path, subdataset, "annotation.jsonl"
81
- )
82
- image_base = os.path.join(split_path, subdataset)
83
-
84
- with open(annotation_path, encoding="utf-8") as f:
85
- for line in f:
86
- line = line.strip()
87
- if not line:
88
- continue
89
-
90
- entry = json.loads(line)
91
- image_path = os.path.join(image_base, entry["image_path"])
92
-
93
- bboxes, labels, categories = [], [], []
94
- for category, boxes in entry["bbox"].items():
95
- for box in boxes:
96
- x_min, y_min = box[0]
97
- x_max, y_max = box[1]
98
- # Convert [[x_min,y_min],[x_max,y_max]] → COCO [x,y,w,h]
99
- bboxes.append(
100
- [
101
- float(x_min),
102
- float(y_min),
103
- float(x_max - x_min),
104
- float(y_max - y_min),
105
- ]
106
- )
107
- labels.append(ALL_CLASSES.index(category))
108
- categories.append(category)
109
-
110
- yield idx, {
111
- "image": image_path,
112
- "image_id": f"{subdataset}/{entry['image_path']}",
113
- "subdataset": subdataset,
114
- "objects": {
115
- "bbox": bboxes,
116
- "label": labels,
117
- "category": categories,
118
- },
119
- }
120
- idx += 1