Datasets:
refactor: csv name feat: upload script
Browse files
data/{outdoor_garbage_dataset.csv → outdoor_garbage.csv}
RENAMED
|
File without changes
|
outdoor_garbage.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import datasets
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
_CITATION = """\
|
| 5 |
+
@InProceedings{huggingface:dataset,
|
| 6 |
+
title = {outdoor_garbage},
|
| 7 |
+
author = {TrainingDataPro},
|
| 8 |
+
year = {2023}
|
| 9 |
+
}
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
_DESCRIPTION = """\
|
| 13 |
+
The dataset consisting of garbage cans of various capacities and types.
|
| 14 |
+
Best to train a neural network to monitor the timely removal of garbage and
|
| 15 |
+
organize the logistics of vehicles for garbage collection. Dataset is useful
|
| 16 |
+
for the recommendation systems, optimization and automization the work of
|
| 17 |
+
community services, smart city.
|
| 18 |
+
"""
|
| 19 |
+
_NAME = 'outdoor_garbage'
|
| 20 |
+
|
| 21 |
+
_HOMEPAGE = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}"
|
| 22 |
+
|
| 23 |
+
_LICENSE = ""
|
| 24 |
+
|
| 25 |
+
_DATA = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}/resolve/main/data/"
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class OutdoorGarbage(datasets.GeneratorBasedBuilder):
|
| 29 |
+
"""Small sample of image-text pairs"""
|
| 30 |
+
|
| 31 |
+
def _info(self):
|
| 32 |
+
return datasets.DatasetInfo(
|
| 33 |
+
description=_DESCRIPTION,
|
| 34 |
+
features=datasets.Features({
|
| 35 |
+
'image_id': datasets.Value('int32'),
|
| 36 |
+
'image': datasets.Image(),
|
| 37 |
+
'annotations': datasets.Value('string')
|
| 38 |
+
}),
|
| 39 |
+
supervised_keys=None,
|
| 40 |
+
homepage=_HOMEPAGE,
|
| 41 |
+
citation=_CITATION,
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
def _split_generators(self, dl_manager):
|
| 45 |
+
images = dl_manager.download(f"{_DATA}images.tar.gz")
|
| 46 |
+
annotations = dl_manager.download(f"{_DATA}{_NAME}.csv")
|
| 47 |
+
images = dl_manager.iter_archive(images)
|
| 48 |
+
return [
|
| 49 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN,
|
| 50 |
+
gen_kwargs={
|
| 51 |
+
"images": images,
|
| 52 |
+
'annotations': annotations
|
| 53 |
+
}),
|
| 54 |
+
]
|
| 55 |
+
|
| 56 |
+
def _generate_examples(self, images, annotations):
|
| 57 |
+
annotations_df = pd.read_csv(annotations)
|
| 58 |
+
|
| 59 |
+
for idx, (image_path, image) in enumerate(images):
|
| 60 |
+
yield idx, {
|
| 61 |
+
'image_id':
|
| 62 |
+
annotations_df.loc[
|
| 63 |
+
annotations_df['image_name'] == image_path]
|
| 64 |
+
['image_id'].values[0],
|
| 65 |
+
"image": {
|
| 66 |
+
"path": image_path,
|
| 67 |
+
"bytes": image.read()
|
| 68 |
+
},
|
| 69 |
+
'annotations':
|
| 70 |
+
annotations_df.loc[
|
| 71 |
+
annotations_df['image_name'] == image_path]
|
| 72 |
+
['annotations'].values[0]
|
| 73 |
+
}
|