|
|
|
|
|
|
|
|
""" |
|
|
@File : FE-Wireframe.py |
|
|
@Time : 2025/08/31 23:00:00 |
|
|
@Author : lh9171338 |
|
|
@Version : 1.0 |
|
|
@Contact : [email protected] |
|
|
""" |
|
|
|
|
|
import os |
|
|
import numpy as np |
|
|
import json |
|
|
import datasets |
|
|
from datasets import Features, Image, Sequence, Value |
|
|
|
|
|
|
|
|
_CITATION = """\ |
|
|
@ARTICLE{10323537, |
|
|
author={Yu, Huai and Li, Hao and Yang, Wen and Yu, Lei and Xia, Gui-Song}, |
|
|
journal={IEEE Transactions on Pattern Analysis and Machine Intelligence}, |
|
|
title={Detecting Line Segments in Motion-Blurred Images With Events}, |
|
|
year={2023}, |
|
|
pages={1-16}, |
|
|
doi={10.1109/TPAMI.2023.3334877} |
|
|
} |
|
|
""" |
|
|
_DESCRIPTION = """\ |
|
|
This new dataset is designed for motion-blurred image line segment detection with events. |
|
|
""" |
|
|
_HOMEPAGE = "" |
|
|
_LICENSE = "mit" |
|
|
|
|
|
|
|
|
class FEBlurframe(datasets.GeneratorBasedBuilder): |
|
|
"""FE-Blurframe Dataset""" |
|
|
|
|
|
VERSION = datasets.Version("1.1.0") |
|
|
|
|
|
def _info(self): |
|
|
"""infos""" |
|
|
features = Features( |
|
|
{ |
|
|
"blur_image": Image(), |
|
|
"start_image": Image(), |
|
|
"end_image": Image(), |
|
|
"events": { |
|
|
"image_size": Sequence(Value("int32")), |
|
|
"x": Sequence(Value("int16")), |
|
|
"y": Sequence(Value("int16")), |
|
|
"t": Sequence(Value("int32")), |
|
|
"p": Sequence(Value("bool")), |
|
|
}, |
|
|
"H": Sequence(Sequence(Value("float32"))), |
|
|
"image_size": Sequence(Value("int32")), |
|
|
"junc": Sequence(Sequence(Value("float32"))), |
|
|
"flow": Sequence(Sequence(Value("float32"))), |
|
|
"lines": Sequence(Sequence(Value("float32"))), |
|
|
"edges_positive": Sequence(Sequence(Value("float32"))), |
|
|
} |
|
|
) |
|
|
return datasets.DatasetInfo( |
|
|
description=_DESCRIPTION, |
|
|
features=features, |
|
|
homepage=_HOMEPAGE, |
|
|
license=_LICENSE, |
|
|
citation=_CITATION, |
|
|
) |
|
|
|
|
|
def _split_generators(self, dl_manager): |
|
|
"""split generators""" |
|
|
data_files = { |
|
|
"train": "train.jsonl", |
|
|
"test": "test.jsonl", |
|
|
"events_raw": "events_raw.zip", |
|
|
"images-blur": "images-blur.zip", |
|
|
"images-start": "images-start.zip", |
|
|
"images-end": "images-end.zip", |
|
|
} |
|
|
data_files = dl_manager.download_and_extract(data_files) |
|
|
print(f"data_files: {data_files}") |
|
|
return [ |
|
|
datasets.SplitGenerator( |
|
|
name=datasets.Split.TRAIN, |
|
|
gen_kwargs={ |
|
|
"filepath": data_files["train"], |
|
|
"data_files": data_files, |
|
|
}, |
|
|
), |
|
|
datasets.SplitGenerator( |
|
|
name=datasets.Split.TEST, |
|
|
gen_kwargs={ |
|
|
"filepath": data_files["test"], |
|
|
"data_files": data_files, |
|
|
}, |
|
|
), |
|
|
] |
|
|
|
|
|
def _generate_examples(self, filepath, data_files): |
|
|
"""generate examples""" |
|
|
with open(filepath, encoding="utf-8") as f: |
|
|
lines = f.readlines() |
|
|
for idx, line in enumerate(lines): |
|
|
info = json.loads(line) |
|
|
new_info = dict() |
|
|
new_info["blur_image"] = os.path.join(data_files["images-blur"], "images-blur", info["filename"]) |
|
|
new_info["start_image"] = os.path.join(data_files["images-start"], "images-start", info["filename"]) |
|
|
new_info["end_image"] = os.path.join(data_files["images-end"], "images-end", info["filename"]) |
|
|
events = np.load( |
|
|
os.path.join(data_files["events_raw"], "events_raw", info["filename"].replace(".png", ".npz")) |
|
|
) |
|
|
new_info["events"] = dict(**events) |
|
|
for key in ["image_size", "H", "junc", "flow", "lines", "edges_positive"]: |
|
|
new_info[key] = info[key] |
|
|
yield idx, new_info |
|
|
|