2 Copyright (c) 2019 Intel Corporation
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
20 from .base_representation import BaseRepresentation
21 from ..data_readers import BaseReader
29 class SuperResolutionRepresentation(BaseRepresentation):
33 class SuperResolutionAnnotation(SuperResolutionRepresentation):
35 GTLoader.PILLOW: 'pillow_imread',
36 GTLoader.OPENCV: 'opencv_imread'
39 def __init__(self, identifier, path_to_hr, gt_loader=GTLoader.PILLOW):
42 identifier: object identifier (e.g. image name).
43 path_to_hr: path where height resolution image should be loaded from. The path is relative to data source.
44 gt_loader: back-end, used to load segmentation masks.
47 super().__init__(identifier)
48 self._image_path = path_to_hr
49 self._gt_loader = self.LOADERS.get(gt_loader)
53 loader = BaseReader.provide(self._gt_loader)
54 gt = loader.read(self._image_path, self.metadata['data_source'])
55 return gt.astype(np.uint8)
58 class SuperResolutionPrediction(SuperResolutionRepresentation):
59 def __init__(self, identifiers, prediction):
62 identifiers: object identifier (e.g. image name).
63 prediction: array with shape (height, width) contained result image.
66 super().__init__(identifiers)
67 self.value = prediction