Datasets:
Tasks:
Image Classification
Size Categories:
1K<n<10K
Language Creators:
crowdsourced
Annotations Creators:
crowdsourced
Source Datasets:
original
Tags:
License:
# Copyright (C) 2022, Pyronear. | |
# This program is licensed under the Apache License 2.0. | |
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0> for full license details. | |
"""OpenFire dataset.""" | |
import os | |
import json | |
import datasets | |
_HOMEPAGE = "https://pyronear.org/pyro-vision/datasets.html#openfire" | |
_LICENSE = "Apache License 2.0" | |
_CITATION = """\ | |
@software{Pyronear_PyroVision_2019, | |
title={Pyrovision: wildfire early detection}, | |
author={Pyronear contributors}, | |
year={2019}, | |
month={October}, | |
publisher = {GitHub}, | |
url = {https://github.com/pyronear/pyro-vision} | |
} | |
""" | |
_DESCRIPTION = """\ | |
OpenFire is an image classification dataset for wildfire detection, collected | |
from web searches. | |
""" | |
_REPO = "https://huggingface.co/datasets/pyronear/openfire/resolve/main/data" | |
_URLS = { | |
"train": f"{_REPO}/openfire_train.json", | |
"validation": f"{_REPO}/openfire_val.json", | |
} | |
class OpenFire(datasets.GeneratorBasedBuilder): | |
"""OpenFire dataset.""" | |
VERSION = datasets.Version("1.0.0") | |
def _info(self): | |
return datasets.DatasetInfo( | |
description=_DESCRIPTION, | |
features=datasets.Features( | |
{ | |
"image_url": datasets.Value("string", id=None), | |
"is_wildfire": datasets.Value("bool"), | |
} | |
), | |
supervised_keys=None, | |
homepage=_HOMEPAGE, | |
license=_LICENSE, | |
citation=_CITATION, | |
) | |
def _split_generators(self, dl_manager): | |
data_dir = dl_manager.download_and_extract(_URLS) | |
return [ | |
datasets.SplitGenerator( | |
name=datasets.Split.TRAIN, | |
gen_kwargs={ | |
"filepath": data_dir["train"], | |
"split": "train", | |
}, | |
), | |
datasets.SplitGenerator( | |
name=datasets.Split.VALIDATION, | |
gen_kwargs={ | |
"filepath": data_dir["validation"], | |
"split": "validation", | |
}, | |
), | |
] | |
def _generate_examples(self, filepath, split): | |
with open(filepath, "rb") as f: | |
urls = json.load(f) | |
idx = 0 | |
for label in range(2): | |
for url in urls[str(label)]: | |
yield idx, {"image_url": url, "is_wildfire": bool(label)} | |
idx += 1 | |