Datasets:
Convert to parquet (loading scripts are no longer supported)
#2
by davanstrien HF Staff - opened
- COCO/test-00000-of-00001.parquet +3 -0
- COCO/train-00000-of-00001.parquet +3 -0
- COCO/val-00000-of-00001.parquet +3 -0
- README.md +94 -0
- YOLO/test-00000-of-00001.parquet +3 -0
- YOLO/train-00000-of-00001.parquet +3 -0
- YOLO/val-00000-of-00001.parquet +3 -0
- dataset_infos.json +1 -1
- yalta_ai_tabular_dataset.py +0 -242
COCO/test-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e31c133b8b8fa29a0d173b973873b7c5035c70656f716ba0f9e5ae10196a2ae1
|
| 3 |
+
size 59632002
|
COCO/train-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:871ac472a02f4773f1b6c63d66d01147e693069437b6aa3da81df848261d89ec
|
| 3 |
+
size 281375209
|
COCO/val-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1862401aeb2fca832606ab45e4074e56f4f5707276fcda573409abf7784ed31f
|
| 3 |
+
size 37200443
|
README.md
CHANGED
|
@@ -17,6 +17,100 @@ tags:
|
|
| 17 |
task_categories:
|
| 18 |
- object-detection
|
| 19 |
task_ids: []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
---
|
| 21 |
|
| 22 |
# YALTAi Tabular Dataset
|
|
|
|
| 17 |
task_categories:
|
| 18 |
- object-detection
|
| 19 |
task_ids: []
|
| 20 |
+
dataset_info:
|
| 21 |
+
- config_name: COCO
|
| 22 |
+
features:
|
| 23 |
+
- name: image_id
|
| 24 |
+
dtype: int64
|
| 25 |
+
- name: image
|
| 26 |
+
dtype: image
|
| 27 |
+
- name: width
|
| 28 |
+
dtype: int32
|
| 29 |
+
- name: height
|
| 30 |
+
dtype: int32
|
| 31 |
+
- name: objects
|
| 32 |
+
list:
|
| 33 |
+
- name: category_id
|
| 34 |
+
dtype:
|
| 35 |
+
class_label:
|
| 36 |
+
names:
|
| 37 |
+
'0': Header
|
| 38 |
+
'1': Col
|
| 39 |
+
'2': Marginal
|
| 40 |
+
'3': text
|
| 41 |
+
- name: image_id
|
| 42 |
+
dtype: int64
|
| 43 |
+
- name: id
|
| 44 |
+
dtype: int64
|
| 45 |
+
- name: area
|
| 46 |
+
dtype: int64
|
| 47 |
+
- name: bbox
|
| 48 |
+
list: float32
|
| 49 |
+
length: 4
|
| 50 |
+
- name: segmentation
|
| 51 |
+
list:
|
| 52 |
+
list: float32
|
| 53 |
+
- name: iscrowd
|
| 54 |
+
dtype: bool
|
| 55 |
+
splits:
|
| 56 |
+
- name: train
|
| 57 |
+
num_bytes: 281355547
|
| 58 |
+
num_examples: 196
|
| 59 |
+
- name: val
|
| 60 |
+
num_bytes: 37193267
|
| 61 |
+
num_examples: 22
|
| 62 |
+
- name: test
|
| 63 |
+
num_bytes: 59622681
|
| 64 |
+
num_examples: 135
|
| 65 |
+
download_size: 378207654
|
| 66 |
+
dataset_size: 378171495
|
| 67 |
+
- config_name: YOLO
|
| 68 |
+
features:
|
| 69 |
+
- name: image
|
| 70 |
+
dtype: image
|
| 71 |
+
- name: objects
|
| 72 |
+
struct:
|
| 73 |
+
- name: label
|
| 74 |
+
list:
|
| 75 |
+
class_label:
|
| 76 |
+
names:
|
| 77 |
+
'0': Header
|
| 78 |
+
'1': Col
|
| 79 |
+
'2': Marginal
|
| 80 |
+
'3': text
|
| 81 |
+
- name: bbox
|
| 82 |
+
list:
|
| 83 |
+
list: int32
|
| 84 |
+
length: 4
|
| 85 |
+
splits:
|
| 86 |
+
- name: train
|
| 87 |
+
num_bytes: 281327882
|
| 88 |
+
num_examples: 196
|
| 89 |
+
- name: val
|
| 90 |
+
num_bytes: 37189262
|
| 91 |
+
num_examples: 22
|
| 92 |
+
- name: test
|
| 93 |
+
num_bytes: 59596564
|
| 94 |
+
num_examples: 135
|
| 95 |
+
download_size: 378142580
|
| 96 |
+
dataset_size: 378113708
|
| 97 |
+
configs:
|
| 98 |
+
- config_name: COCO
|
| 99 |
+
data_files:
|
| 100 |
+
- split: train
|
| 101 |
+
path: COCO/train-*
|
| 102 |
+
- split: val
|
| 103 |
+
path: COCO/val-*
|
| 104 |
+
- split: test
|
| 105 |
+
path: COCO/test-*
|
| 106 |
+
- config_name: YOLO
|
| 107 |
+
data_files:
|
| 108 |
+
- split: train
|
| 109 |
+
path: YOLO/train-*
|
| 110 |
+
- split: val
|
| 111 |
+
path: YOLO/val-*
|
| 112 |
+
- split: test
|
| 113 |
+
path: YOLO/test-*
|
| 114 |
---
|
| 115 |
|
| 116 |
# YALTAi Tabular Dataset
|
YOLO/test-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:76a598033925742899099d200e90b5053d0100082d9940ad211ecf9829e6ac59
|
| 3 |
+
size 59604963
|
YOLO/train-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fc89f2873614e06d20cf94d994bbfda4500a34e7655b206ffdfaa830576cdf9c
|
| 3 |
+
size 281344230
|
YOLO/val-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:801488859900211e562457987f466d73a2940746c956f5aead634616360fa7cc
|
| 3 |
+
size 37193387
|
dataset_infos.json
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
{"default": {"description": "TODO", "citation": " @dataset{clerice_thibault_2022_6827706,\n author = {Cl\u00e9rice, Thibault},\n title = {YALTAi: Tabular Dataset},\n month = jul,\n year = 2022,\n publisher = {Zenodo},\n version = {1.0.0},\n doi = {10.5281/zenodo.6827706},\n url = {https://doi.org/10.5281/zenodo.6827706}\n}\n", "homepage": "https://doi.org/10.5281/zenodo.6827706", "license": "Creative Commons Attribution 4.0 International", "features": {"image": {"decode": true, "id": null, "_type": "Image"}, "objects": {"feature": {"label": {"num_classes": 4, "names": ["Header", "Col", "Marginal", "text"], "id": null, "_type": "ClassLabel"}, "bbox": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": 4, "id": null, "_type": "Sequence"}}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "yalt_ai_tabular_dataset", "config_name": "default", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 60704, "num_examples": 196, "dataset_name": "yalt_ai_tabular_dataset"}, "validation": {"name": "validation", "num_bytes": 7537, "num_examples": 22, "dataset_name": "yalt_ai_tabular_dataset"}, "test": {"name": "test", "num_bytes": 47159, "num_examples": 135, "dataset_name": "yalt_ai_tabular_dataset"}}, "download_checksums": {"https://zenodo.org/record/6827706/files/yaltai-table.zip?download=1": {"num_bytes": 376190064, "checksum": "5b312faf097939302fb98ab0a8b35c007962d88978ea9dc28d2f560b89dc0657"}}, "download_size": 376190064, "post_processing_size": null, "dataset_size": 115400, "size_in_bytes": 376305464}, "YOLO": {"description": "
|
|
|
|
| 1 |
+
{"default": {"description": "TODO", "citation": " @dataset{clerice_thibault_2022_6827706,\n author = {Cl\u00e9rice, Thibault},\n title = {YALTAi: Tabular Dataset},\n month = jul,\n year = 2022,\n publisher = {Zenodo},\n version = {1.0.0},\n doi = {10.5281/zenodo.6827706},\n url = {https://doi.org/10.5281/zenodo.6827706}\n}\n", "homepage": "https://doi.org/10.5281/zenodo.6827706", "license": "Creative Commons Attribution 4.0 International", "features": {"image": {"decode": true, "id": null, "_type": "Image"}, "objects": {"feature": {"label": {"num_classes": 4, "names": ["Header", "Col", "Marginal", "text"], "id": null, "_type": "ClassLabel"}, "bbox": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": 4, "id": null, "_type": "Sequence"}}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "yalt_ai_tabular_dataset", "config_name": "default", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 60704, "num_examples": 196, "dataset_name": "yalt_ai_tabular_dataset"}, "validation": {"name": "validation", "num_bytes": 7537, "num_examples": 22, "dataset_name": "yalt_ai_tabular_dataset"}, "test": {"name": "test", "num_bytes": 47159, "num_examples": 135, "dataset_name": "yalt_ai_tabular_dataset"}}, "download_checksums": {"https://zenodo.org/record/6827706/files/yaltai-table.zip?download=1": {"num_bytes": 376190064, "checksum": "5b312faf097939302fb98ab0a8b35c007962d88978ea9dc28d2f560b89dc0657"}}, "download_size": 376190064, "post_processing_size": null, "dataset_size": 115400, "size_in_bytes": 376305464}, "YOLO": {"description": "", "citation": "", "homepage": "", "license": "", "features": {"image": {"_type": "Image"}, "objects": {"label": {"feature": {"names": ["Header", "Col", "Marginal", "text"], "_type": "ClassLabel"}, "_type": "List"}, "bbox": {"feature": {"feature": {"dtype": "int32", "_type": "Value"}, "length": 4, "_type": "List"}, "_type": "List"}}}, "config_name": "YOLO", "splits": {"train": {"name": "train", "num_bytes": 281327882, "num_examples": 196, "dataset_name": null}, "val": {"name": "val", "num_bytes": 37189262, "num_examples": 22, "dataset_name": null}, "test": {"name": "test", "num_bytes": 59596564, "num_examples": 135, "dataset_name": null}}, "download_size": 378142580, "dataset_size": 378113708, "size_in_bytes": 756256288}, "COCO": {"description": "", "citation": "", "homepage": "", "license": "", "features": {"image_id": {"dtype": "int64", "_type": "Value"}, "image": {"_type": "Image"}, "width": {"dtype": "int32", "_type": "Value"}, "height": {"dtype": "int32", "_type": "Value"}, "objects": {"feature": {"category_id": {"names": ["Header", "Col", "Marginal", "text"], "_type": "ClassLabel"}, "image_id": {"dtype": "int64", "_type": "Value"}, "id": {"dtype": "int64", "_type": "Value"}, "area": {"dtype": "int64", "_type": "Value"}, "bbox": {"feature": {"dtype": "float32", "_type": "Value"}, "length": 4, "_type": "List"}, "segmentation": {"feature": {"feature": {"dtype": "float32", "_type": "Value"}, "_type": "List"}, "_type": "List"}, "iscrowd": {"dtype": "bool", "_type": "Value"}}, "_type": "List"}}, "config_name": "COCO", "splits": {"train": {"name": "train", "num_bytes": 281355547, "num_examples": 196, "dataset_name": null}, "val": {"name": "val", "num_bytes": 37193267, "num_examples": 22, "dataset_name": null}, "test": {"name": "test", "num_bytes": 59622681, "num_examples": 135, "dataset_name": null}}, "download_size": 378207654, "dataset_size": 378171495, "size_in_bytes": 756379149}}
|
yalta_ai_tabular_dataset.py
DELETED
|
@@ -1,242 +0,0 @@
|
|
| 1 |
-
# Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 2 |
-
#
|
| 3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
-
# you may not use this file except in compliance with the License.
|
| 5 |
-
# You may obtain a copy of the License at
|
| 6 |
-
#
|
| 7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
-
#
|
| 9 |
-
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
-
# See the License for the specific language governing permissions and
|
| 13 |
-
# limitations under the License.
|
| 14 |
-
"""Script for reading 'You Actually Look Twice At it (YALTAi)' dataset."""
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
import os
|
| 18 |
-
from glob import glob
|
| 19 |
-
|
| 20 |
-
import datasets
|
| 21 |
-
from PIL import Image
|
| 22 |
-
|
| 23 |
-
_CITATION = """\
|
| 24 |
-
@dataset{clerice_thibault_2022_6827706,
|
| 25 |
-
author = {Clérice, Thibault},
|
| 26 |
-
title = {YALTAi: Tabular Dataset},
|
| 27 |
-
month = jul,
|
| 28 |
-
year = 2022,
|
| 29 |
-
publisher = {Zenodo},
|
| 30 |
-
version = {1.0.0},
|
| 31 |
-
doi = {10.5281/zenodo.6827706},
|
| 32 |
-
url = {https://doi.org/10.5281/zenodo.6827706}
|
| 33 |
-
}
|
| 34 |
-
"""
|
| 35 |
-
|
| 36 |
-
_DESCRIPTION = """Yalt AI Tabular Dataset"""
|
| 37 |
-
|
| 38 |
-
_HOMEPAGE = "https://doi.org/10.5281/zenodo.6827706"
|
| 39 |
-
|
| 40 |
-
_LICENSE = "Creative Commons Attribution 4.0 International"
|
| 41 |
-
|
| 42 |
-
_URL = "https://zenodo.org/record/6827706/files/yaltai-table.zip?download=1"
|
| 43 |
-
|
| 44 |
-
_CATEGORIES = ["Header", "Col", "Marginal", "text"]
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
class YaltAiTabularDatasetConfig(datasets.BuilderConfig):
|
| 48 |
-
"""BuilderConfig for YaltAiTabularDataset."""
|
| 49 |
-
|
| 50 |
-
def __init__(self, name, **kwargs):
|
| 51 |
-
"""BuilderConfig for YaltAiTabularDataset."""
|
| 52 |
-
super(YaltAiTabularDatasetConfig, self).__init__(
|
| 53 |
-
version=datasets.Version("1.0.0"), name=name, description=None, **kwargs
|
| 54 |
-
)
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
class YaltAiTabularDataset(datasets.GeneratorBasedBuilder):
|
| 58 |
-
"""Object Detection for historic manuscripts"""
|
| 59 |
-
|
| 60 |
-
BUILDER_CONFIGS = [
|
| 61 |
-
YaltAiTabularDatasetConfig("YOLO"),
|
| 62 |
-
YaltAiTabularDatasetConfig("COCO"),
|
| 63 |
-
]
|
| 64 |
-
|
| 65 |
-
def _info(self):
|
| 66 |
-
if self.config.name == "COCO":
|
| 67 |
-
features = datasets.Features(
|
| 68 |
-
{
|
| 69 |
-
"image_id": datasets.Value("int64"),
|
| 70 |
-
"image": datasets.Image(),
|
| 71 |
-
"width": datasets.Value("int32"),
|
| 72 |
-
"height": datasets.Value("int32"),
|
| 73 |
-
}
|
| 74 |
-
)
|
| 75 |
-
object_dict = {
|
| 76 |
-
"category_id": datasets.ClassLabel(names=_CATEGORIES),
|
| 77 |
-
"image_id": datasets.Value("string"),
|
| 78 |
-
"id": datasets.Value("int64"),
|
| 79 |
-
"area": datasets.Value("int64"),
|
| 80 |
-
"bbox": datasets.Sequence(datasets.Value("float32"), length=4),
|
| 81 |
-
"segmentation": [[datasets.Value("float32")]],
|
| 82 |
-
"iscrowd": datasets.Value("bool"),
|
| 83 |
-
}
|
| 84 |
-
features["objects"] = [object_dict]
|
| 85 |
-
if self.config.name == "YOLO":
|
| 86 |
-
features = datasets.Features(
|
| 87 |
-
{
|
| 88 |
-
"image": datasets.Image(),
|
| 89 |
-
"objects": datasets.Sequence(
|
| 90 |
-
{
|
| 91 |
-
"label": datasets.ClassLabel(names=_CATEGORIES),
|
| 92 |
-
"bbox": datasets.Sequence(
|
| 93 |
-
datasets.Value("int32"), length=4
|
| 94 |
-
),
|
| 95 |
-
}
|
| 96 |
-
),
|
| 97 |
-
}
|
| 98 |
-
)
|
| 99 |
-
return datasets.DatasetInfo(
|
| 100 |
-
features=features,
|
| 101 |
-
supervised_keys=None,
|
| 102 |
-
description=_DESCRIPTION,
|
| 103 |
-
homepage=_HOMEPAGE,
|
| 104 |
-
license=_LICENSE,
|
| 105 |
-
citation=_CITATION,
|
| 106 |
-
)
|
| 107 |
-
|
| 108 |
-
def _split_generators(self, dl_manager):
|
| 109 |
-
data_dir = dl_manager.download_and_extract(_URL)
|
| 110 |
-
return [
|
| 111 |
-
datasets.SplitGenerator(
|
| 112 |
-
name=datasets.Split.TRAIN,
|
| 113 |
-
gen_kwargs={
|
| 114 |
-
"data_dir": os.path.join(data_dir, "yaltai-table/", "train")
|
| 115 |
-
},
|
| 116 |
-
),
|
| 117 |
-
datasets.SplitGenerator(
|
| 118 |
-
name=datasets.Split.VALIDATION,
|
| 119 |
-
gen_kwargs={"data_dir": os.path.join(data_dir, "yaltai-table/", "val")},
|
| 120 |
-
),
|
| 121 |
-
datasets.SplitGenerator(
|
| 122 |
-
name=datasets.Split.TEST,
|
| 123 |
-
gen_kwargs={
|
| 124 |
-
"data_dir": os.path.join(data_dir, "yaltai-table/", "test")
|
| 125 |
-
},
|
| 126 |
-
),
|
| 127 |
-
]
|
| 128 |
-
|
| 129 |
-
def _generate_examples(self, data_dir):
|
| 130 |
-
def create_annotation_from_yolo_format(
|
| 131 |
-
min_x,
|
| 132 |
-
min_y,
|
| 133 |
-
width,
|
| 134 |
-
height,
|
| 135 |
-
image_id,
|
| 136 |
-
category_id,
|
| 137 |
-
annotation_id,
|
| 138 |
-
segmentation=False,
|
| 139 |
-
):
|
| 140 |
-
bbox = (float(min_x), float(min_y), float(width), float(height))
|
| 141 |
-
area = width * height
|
| 142 |
-
max_x = min_x + width
|
| 143 |
-
max_y = min_y + height
|
| 144 |
-
if segmentation:
|
| 145 |
-
seg = [[min_x, min_y, max_x, min_y, max_x, max_y, min_x, max_y]]
|
| 146 |
-
else:
|
| 147 |
-
seg = []
|
| 148 |
-
return {
|
| 149 |
-
"id": annotation_id,
|
| 150 |
-
"image_id": image_id,
|
| 151 |
-
"bbox": bbox,
|
| 152 |
-
"area": area,
|
| 153 |
-
"iscrowd": 0,
|
| 154 |
-
"category_id": category_id,
|
| 155 |
-
"segmentation": seg,
|
| 156 |
-
}
|
| 157 |
-
|
| 158 |
-
image_dir = os.path.join(data_dir, "images")
|
| 159 |
-
label_dir = os.path.join(data_dir, "labels")
|
| 160 |
-
image_paths = sorted(glob(f"{image_dir}/*.jpg"))
|
| 161 |
-
label_paths = sorted(glob(f"{label_dir}/*.txt"))
|
| 162 |
-
if self.config.name == "COCO":
|
| 163 |
-
for idx, (image_path, label_path) in enumerate(
|
| 164 |
-
zip(image_paths, label_paths)
|
| 165 |
-
):
|
| 166 |
-
image_id = idx
|
| 167 |
-
annotations = []
|
| 168 |
-
image = Image.open(image_path) # Possibly conver to RGB?
|
| 169 |
-
w, h = image.size
|
| 170 |
-
with open(label_path, "r") as f:
|
| 171 |
-
lines = f.readlines()
|
| 172 |
-
for line in lines:
|
| 173 |
-
line = line.strip().split()
|
| 174 |
-
category_id = line[0]
|
| 175 |
-
x_center = float(line[1])
|
| 176 |
-
y_center = float(line[2])
|
| 177 |
-
width = float(line[3])
|
| 178 |
-
height = float(line[4])
|
| 179 |
-
|
| 180 |
-
float_x_center = w * x_center
|
| 181 |
-
float_y_center = h * y_center
|
| 182 |
-
float_width = w * width
|
| 183 |
-
float_height = h * height
|
| 184 |
-
|
| 185 |
-
min_x = int(float_x_center - float_width / 2)
|
| 186 |
-
min_y = int(float_y_center - float_height / 2)
|
| 187 |
-
width = int(float_width)
|
| 188 |
-
height = int(float_height)
|
| 189 |
-
|
| 190 |
-
annotation = create_annotation_from_yolo_format(
|
| 191 |
-
min_x,
|
| 192 |
-
min_y,
|
| 193 |
-
width,
|
| 194 |
-
height,
|
| 195 |
-
image_id,
|
| 196 |
-
category_id,
|
| 197 |
-
image_id,
|
| 198 |
-
)
|
| 199 |
-
annotations.append(annotation)
|
| 200 |
-
|
| 201 |
-
example = {
|
| 202 |
-
"image_id": image_id,
|
| 203 |
-
"image": image,
|
| 204 |
-
"width": w,
|
| 205 |
-
"height": h,
|
| 206 |
-
"objects": annotations,
|
| 207 |
-
}
|
| 208 |
-
yield idx, example
|
| 209 |
-
if self.config.name == "YOLO":
|
| 210 |
-
for idx, (image_path, label_path) in enumerate(
|
| 211 |
-
zip(image_paths, label_paths)
|
| 212 |
-
):
|
| 213 |
-
im = Image.open(image_path)
|
| 214 |
-
width, height = im.size
|
| 215 |
-
image_id = idx
|
| 216 |
-
annotations = []
|
| 217 |
-
with open(label_path, "r") as f:
|
| 218 |
-
lines = f.readlines()
|
| 219 |
-
objects = []
|
| 220 |
-
for line in lines:
|
| 221 |
-
line = line.strip().split()
|
| 222 |
-
bbox_class = int(line[0])
|
| 223 |
-
bbox_xcenter = int(float(line[1]) * width)
|
| 224 |
-
bbox_ycenter = int(float(line[2]) * height)
|
| 225 |
-
bbox_width = int(float(line[3]) * width)
|
| 226 |
-
bbox_height = int(float(line[4]) * height)
|
| 227 |
-
objects.append(
|
| 228 |
-
{
|
| 229 |
-
"label": bbox_class,
|
| 230 |
-
"bbox": [
|
| 231 |
-
bbox_xcenter,
|
| 232 |
-
bbox_ycenter,
|
| 233 |
-
bbox_width,
|
| 234 |
-
bbox_height,
|
| 235 |
-
],
|
| 236 |
-
}
|
| 237 |
-
)
|
| 238 |
-
|
| 239 |
-
yield idx, {
|
| 240 |
-
"image": image_path,
|
| 241 |
-
"objects": objects,
|
| 242 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