Shortcuts

Note

You are reading the documentation for MMEditing 0.x, which will soon be deprecated by the end of 2022. We recommend you upgrade to MMEditing 1.0 to enjoy fruitful new features and better performance brought by OpenMMLab 2.0. Check out the changelog, code and documentation of MMEditing 1.0 for more details.

Source code for mmedit.datasets.img_inpainting_dataset

# Copyright (c) OpenMMLab. All rights reserved.
from pathlib import Path

from .base_dataset import BaseDataset
from .registry import DATASETS


[docs]@DATASETS.register_module() class ImgInpaintingDataset(BaseDataset): """Image dataset for inpainting.""" def __init__(self, ann_file, pipeline, data_prefix=None, test_mode=False): super().__init__(pipeline, test_mode) self.ann_file = str(ann_file) self.data_prefix = str(data_prefix) self.data_infos = self.load_annotations()
[docs] def load_annotations(self): """Load annotations for dataset. Returns: list[dict]: Contain dataset annotations. """ with open(self.ann_file, 'r') as f: img_infos = [] for idx, line in enumerate(f): line = line.strip() _info = dict() line_split = line.split(' ') _info = dict( gt_img_path=Path(self.data_prefix).joinpath( line_split[0]).as_posix(), gt_img_idx=idx) img_infos.append(_info) return img_infos
def evaluate(self, outputs, logger=None, **kwargs): metric_keys = outputs[0]['eval_result'].keys() stats = {} for key in metric_keys: val = sum([x['eval_result'][key] for x in outputs]) val /= self.__len__() stats[key] = val return stats
Read the Docs v: latest
Versions
latest
stable
1.x
v0.16.0
v0.15.2
v0.15.1
v0.15.0
v0.14.0
v0.13.0
v0.12.0
dev-1.x
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.