How to use _build_param_dict method in rester

Best Python code snippet using rester_python

transform_wrappers.py

Source:transform_wrappers.py Github

copy

Full Screen

1from PIL import Image2def _build_param_dict(conf, required_params, optional_params=[],3 key_renames={}, kwargs={}):4 # Filter out params which are passed in kwargs5 required_params = [p for p in required_params if p not in kwargs]6 param_dict = conf.to_param_dict(required_params,7 optional_params.copy(),8 key_renames)9 param_dict.update(kwargs)10 return param_dict11def get_sr_transform(conf, mode, **kwargs):12 def _get_interp(method):13 if method == 'bilinear':14 return Image.BILINEAR15 elif method == 'bicubic':16 return Image.BICUBIC17 else:18 raise ValueError('Unknown interpolation method {}'.format(method))19 assert mode in ('train', 'test')20 required_params = [21 'train_crop_size', 'upscale_factor'22 ]23 # Maps keys in configuration to parameter names in transform functions24 key_renames = {25 'train_crop_size': 'crop_size',26 'test_crop_size': 'crop_size',27 'scale_to_orig': 'upscale'28 }29 if mode == 'train':30 from data.sr_transforms import sr_train_transform31 optional_params = {32 'scale_to_orig': False,33 'interpolation': 'bilinear'34 }35 param_dict = _build_param_dict(conf,36 required_params,37 optional_params,38 key_renames,39 kwargs)40 param_dict['interpolation'] = _get_interp(param_dict['interpolation'])41 transform = sr_train_transform(**param_dict)42 else:43 from data.sr_transforms import sr_test_transform44 optional_params = {45 'scale_to_orig': False,46 'interpolation': 'bilinear',47 'full_image': False48 }49 param_dict = _build_param_dict(conf,50 required_params,51 optional_params,52 key_renames,53 kwargs)54 param_dict['interpolation'] = _get_interp(param_dict['interpolation'])55 transform = sr_test_transform(**param_dict)56 return transform57def get_sr_output_transform(conf, mode, **kwargs):58 assert mode in ('train', 'test', 'output')59 if mode == 'train':60 from data.sr_transforms import sr_output_train_transform61 transform = sr_output_train_transform(convert_luma=True)62 else:63 from data.sr_transforms import sr_output_test_transform64 if mode == 'test':65 param_dict = _build_param_dict(conf,66 ['upscale_factor'],67 kwargs={'crop_border_pixels': True,68 'convert_luma': True})69 else:70 param_dict = _build_param_dict(conf,71 ['upscale_factor'])72 transform = sr_output_test_transform(**param_dict)73 return transform74def get_output_transform(conf, application, mode, **kwargs):75 applications = {76 'super_resolution': get_sr_output_transform,77 }78 assert application in applications...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run rester automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful