Spaces:
Running
Running
File size: 1,348 Bytes
0f2d9f6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import sys
import cv2
import os.path as osp
root_path = osp.abspath(osp.join(__file__, osp.pardir, osp.pardir))
sys.path.append(root_path)
from preprocessing.dataset_creation_utils import get_sr_method
from feature_extraction.features_extractor import FeaturesExtractor
class EyeDentityDatasetCreation:
def __init__(self, feature_extraction_configs, sr_configs=None):
self.extraction_library = feature_extraction_configs["extraction_library"]
self.sr_configs = sr_configs
if self.sr_configs:
self.sr_method_name = sr_configs["method"]
self.upscale = sr_configs["params"]["upscale"]
if self.sr_method_name != "-":
self.sr_method = get_sr_method(self, sr_configs)
else:
self.upscale = 1
self.blink_detection = feature_extraction_configs["blink_detection"]
self.features_extractor = FeaturesExtractor(
extraction_library=self.extraction_library,
blink_detection=self.blink_detection,
upscale=self.upscale,
)
def __call__(self, img):
# img = cv2.imread(img)
if self.sr_configs is None or self.sr_configs != "-":
img = img
else:
img = self.sr_method(img)
result_dict = self.features_extractor(img)
return result_dict
|