Apter commited on
Commit
6bb5048
1 Parent(s): 14e4c1e

Add datafiles.

Browse files
.gitattributes CHANGED
@@ -52,3 +52,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
52
  *.jpg filter=lfs diff=lfs merge=lfs -text
53
  *.jpeg filter=lfs diff=lfs merge=lfs -text
54
  *.webp filter=lfs diff=lfs merge=lfs -text
 
 
 
52
  *.jpg filter=lfs diff=lfs merge=lfs -text
53
  *.jpeg filter=lfs diff=lfs merge=lfs -text
54
  *.webp filter=lfs diff=lfs merge=lfs -text
55
+ train2017.zip filter=lfs diff=lfs merge=lfs -text
56
+ val2017.zip filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,59 @@
1
  ---
2
  license: apache-2.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
  ---
4
+
5
+ ---
6
+ dataset_info:
7
+ - config_name: train
8
+ features:
9
+ - name: filename
10
+ dtype: string
11
+ - name: height
12
+ dtype: int64
13
+ - name: width
14
+ dtype: int64
15
+ - name: ann
16
+ struct:
17
+ - name: bboxes
18
+ sequence:
19
+ sequence: float64
20
+ - name: bboxes_ignore
21
+ sequence:
22
+ sequence: int64
23
+ - name: label_ignore
24
+ sequence: int64
25
+ - name: labels
26
+ sequence: int64
27
+ splits:
28
+ - name: train
29
+ num_bytes: 211748
30
+ num_examples: 500
31
+ download_size: 89624346
32
+ dataset_size: 211748
33
+ - config_name: val
34
+ features:
35
+ - name: filename
36
+ dtype: string
37
+ - name: height
38
+ dtype: int64
39
+ - name: width
40
+ dtype: int64
41
+ - name: ann
42
+ struct:
43
+ - name: bboxes
44
+ sequence:
45
+ sequence: float64
46
+ - name: bboxes_ignore
47
+ sequence:
48
+ sequence: int64
49
+ - name: label_ignore
50
+ sequence: int64
51
+ - name: labels
52
+ sequence: int64
53
+ splits:
54
+ - name: val
55
+ num_bytes: 209868
56
+ num_examples: 500
57
+ download_size: 82654443
58
+ dataset_size: 209868
59
+ ---
annotations/instances_train2017.json ADDED
The diff for this file is too large to render. See raw diff
 
annotations/instances_val2017.json ADDED
The diff for this file is too large to render. See raw diff
 
tiny_coco.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ import datasets
4
+ from pycocotools.coco import COCO
5
+
6
+ _DESCRIPTION = 'A tiny coco2017 dataset example.'
7
+
8
+ _ROOT = 'https://huggingface.co/datasets/Apter/tiny-coco/'
9
+ _URLS = {
10
+ 'train': _ROOT + 'train2017.zip',
11
+ 'train_meta': _ROOT + 'annotations/instances_train2017.json',
12
+ 'val': _ROOT + 'val2017.zip',
13
+ 'val_meta': _ROOT + 'annotations/instances_val2017.json',
14
+ }
15
+
16
+ _CLASSES = ('person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus',
17
+ 'train', 'truck', 'boat', 'traffic light', 'fire hydrant',
18
+ 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog',
19
+ 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe',
20
+ 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
21
+ 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat',
22
+ 'baseball glove', 'skateboard', 'surfboard', 'tennis racket',
23
+ 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl',
24
+ 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot',
25
+ 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
26
+ 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop',
27
+ 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven',
28
+ 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase',
29
+ 'scissors', 'teddy bear', 'hair drier', 'toothbrush')
30
+
31
+
32
+ class TinyCoco(datasets.GeneratorBasedBuilder):
33
+ """TODO: Short description of my dataset."""
34
+
35
+ VERSION = datasets.Version('0.1.0')
36
+
37
+ BUILDER_CONFIGS = [
38
+ datasets.BuilderConfig(
39
+ name='train', version=VERSION, description='Training set'),
40
+ datasets.BuilderConfig(
41
+ name='val', version=VERSION, description='Validation set'),
42
+ ]
43
+ # It's not mandatory to have a default configuration.
44
+ # Just use one if it make sense.
45
+ DEFAULT_CONFIG_NAME = 'train'
46
+
47
+ def _info(self):
48
+ return datasets.DatasetInfo(
49
+ # This is the description that will appear on the datasets page.
50
+ description=_DESCRIPTION
51
+ )
52
+
53
+ def _split_generators(self, dl_manager):
54
+ data_dir = dl_manager.download(_URLS[self.config.name])
55
+ meta = dl_manager.download(_URLS[self.config.name + '_meta'])
56
+ return [
57
+ datasets.SplitGenerator(
58
+ name=self.config.name,
59
+ # These kwargs will be passed to _generate_examples
60
+ gen_kwargs={
61
+ 'img_prefix': data_dir,
62
+ 'ann_file': meta
63
+ })
64
+ ]
65
+
66
+ def _generate_examples(self, img_prefix, ann_file):
67
+ """Parser coco format annotation file."""
68
+ coco = COCO(ann_file)
69
+ cat_ids = coco.getCatIds(_CLASSES)
70
+ cat2label = {cat_id: i for i, cat_id in enumerate(cat_ids)}
71
+ img_ids = coco.getImgIds()
72
+ index = 0
73
+ for i in img_ids:
74
+ sample = dict()
75
+ info = coco.loadImgs([i])[0]
76
+ sample['filename'] = os.path.join(img_prefix, info['file_name'])
77
+ sample['height'] = info['height']
78
+ sample['width'] = info['width']
79
+ ann_ids = coco.getAnnIds([i])
80
+ ann_info = coco.loadAnns(ann_ids)
81
+ gt_bboxes = []
82
+ gt_labels = []
83
+ gt_bboxes_ignore = []
84
+ gt_label_ignore = []
85
+ gt_masks_ann = []
86
+ for i, ann in enumerate(ann_info):
87
+ if ann.get('ignore', False):
88
+ continue
89
+ x1, y1, w, h = ann['bbox']
90
+ inter_w = max(0, min(x1 + w, sample['width']) - max(x1, 0))
91
+ inter_h = max(0, min(y1 + h, sample['height']) - max(y1, 0))
92
+ if inter_w * inter_h == 0:
93
+ continue
94
+ if ann['area'] <= 0 or w < 1 or h < 1:
95
+ continue
96
+ if ann['category_id'] not in cat_ids:
97
+ continue
98
+ bbox = [x1, y1, x1 + w, y1 + h]
99
+ if ann.get('iscrowd', False):
100
+ gt_bboxes_ignore.append(bbox)
101
+ gt_label_ignore.append(cat2label[ann['category_id']])
102
+ else:
103
+ gt_bboxes.append(bbox)
104
+ gt_labels.append(cat2label[ann['category_id']])
105
+ gt_masks_ann.append(ann.get('segmentation', None))
106
+
107
+ sample['ann'] = dict(
108
+ bboxes=gt_bboxes,
109
+ labels=gt_labels,
110
+ bboxes_ignore=gt_bboxes_ignore,
111
+ label_ignore=gt_label_ignore)
112
+ yield index, sample
113
+ index += 1
train2017.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a8f8ea150f7ee4533ba213bf3ca2bdf5e9d16b02df92420b90dc439e07ef7433
3
+ size 81827297
val2017.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:49172589a65ac3760aff56027878d986fc3c7897fd5f7b8e81a527bbcf289f34
3
+ size 80303732