How to use patch_config method in yandex-tank

Best Python code snippet using yandex-tank

xception.py

Source: xception.py Github

copy

Full Screen

...8 aligned_xception.preprocess_input)9def AlignedXception41Stride16(*args, **kwargs):10 base = AlignedXception41(*args, **kwargs)11 conf = base.get_config()12 conf = patch_config(conf, ['exit_flow/​block1/​unit1/​sepconv3_depthwise'], 'strides', (1, 1))13 conf = patch_config(conf, ['exit_flow/​block1/​unit1/​shortcut'], 'strides', (1, 1))14 conf = patch_config(conf, ['exit_flow/​block2/​unit1/​sepconv1_depthwise'], 'dilation_rate', (2, 2))15 conf = patch_config(conf, ['exit_flow/​block2/​unit1/​sepconv2_depthwise'], 'dilation_rate', (2, 2))16 conf = patch_config(conf, ['exit_flow/​block2/​unit1/​sepconv3_depthwise'], 'dilation_rate', (2, 2))17 patch = models.Model.from_config(conf)18 patch.set_weights(base.get_weights())19 return patch20def AlignedXception41Stride8(*args, **kwargs):21 base = AlignedXception41(*args, **kwargs)22 conf = base.get_config()23 conf = patch_config(conf, ['entry_flow/​block3/​unit1/​sepconv3_depthwise'], 'strides', (1, 1))24 conf = patch_config(conf, ['entry_flow/​block3/​unit1/​shortcut'], 'strides', (1, 1))25 for i in range(8):26 conf = patch_config(conf, [27 'middle_flow/​block1/​unit{}/​sepconv1_depthwise'.format(i + 1)], 'dilation_rate', (2, 2))28 conf = patch_config(conf, [29 'middle_flow/​block1/​unit{}/​sepconv2_depthwise'.format(i + 1)], 'dilation_rate', (2, 2))30 conf = patch_config(conf, [31 'middle_flow/​block1/​unit{}/​sepconv3_depthwise'.format(i + 1)], 'dilation_rate', (2, 2))32 conf = patch_config(conf, ['exit_flow/​block1/​unit1/​sepconv3_depthwise'], 'strides', (1, 1))33 conf = patch_config(conf, ['exit_flow/​block1/​unit1/​shortcut'], 'strides', (1, 1))34 # Output shape is different when using exit dilation rates like in35 # https:/​/​github.com/​bonlime/​keras-deeplab-v3-plus/​blob/​master/​model.py#L26536 conf = patch_config(conf, ['exit_flow/​block2/​unit1/​sepconv1_depthwise'], 'dilation_rate', (2, 2))37 conf = patch_config(conf, ['exit_flow/​block2/​unit1/​sepconv2_depthwise'], 'dilation_rate', (2, 2))38 conf = patch_config(conf, ['exit_flow/​block2/​unit1/​sepconv3_depthwise'], 'dilation_rate', (2, 2))39 patch = models.Model.from_config(conf)40 patch.set_weights(base.get_weights())41 return patch42AlignedXception65 = partial(43 wrap_bone,44 aligned_xception.Xception65,45 aligned_xception.preprocess_input)46def AlignedXception65Stride16(*args, **kwargs):47 base = AlignedXception65(*args, **kwargs)48 conf = base.get_config()49 conf = patch_config(conf, ['exit_flow/​block1/​unit1/​sepconv3_depthwise'], 'strides', (1, 1))50 conf = patch_config(conf, ['exit_flow/​block1/​unit1/​shortcut'], 'strides', (1, 1))51 conf = patch_config(conf, ['exit_flow/​block2/​unit1/​sepconv1_depthwise'], 'dilation_rate', (2, 2))52 conf = patch_config(conf, ['exit_flow/​block2/​unit1/​sepconv2_depthwise'], 'dilation_rate', (2, 2))53 conf = patch_config(conf, ['exit_flow/​block2/​unit1/​sepconv3_depthwise'], 'dilation_rate', (2, 2))54 patch = models.Model.from_config(conf)55 patch.set_weights(base.get_weights())56 return patch57def AlignedXception65Stride8(*args, **kwargs):58 base = AlignedXception65(*args, **kwargs)59 conf = base.get_config()60 conf = patch_config(conf, ['entry_flow/​block3/​unit1/​sepconv3_depthwise'], 'strides', (1, 1))61 conf = patch_config(conf, ['entry_flow/​block3/​unit1/​shortcut'], 'strides', (1, 1))62 for i in range(16):63 conf = patch_config(conf, [64 'middle_flow/​block1/​unit{}/​sepconv1_depthwise'.format(i + 1)], 'dilation_rate', (2, 2))65 conf = patch_config(conf, [66 'middle_flow/​block1/​unit{}/​sepconv2_depthwise'.format(i + 1)], 'dilation_rate', (2, 2))67 conf = patch_config(conf, [68 'middle_flow/​block1/​unit{}/​sepconv3_depthwise'.format(i + 1)], 'dilation_rate', (2, 2))69 conf = patch_config(conf, ['exit_flow/​block1/​unit1/​sepconv3_depthwise'], 'strides', (1, 1))70 conf = patch_config(conf, ['exit_flow/​block1/​unit1/​shortcut'], 'strides', (1, 1))71 # Output shape is different when using exit dilation rates like in72 # https:/​/​github.com/​bonlime/​keras-deeplab-v3-plus/​blob/​master/​model.py#L26573 conf = patch_config(conf, ['exit_flow/​block2/​unit1/​sepconv1_depthwise'], 'dilation_rate', (2, 2))74 conf = patch_config(conf, ['exit_flow/​block2/​unit1/​sepconv2_depthwise'], 'dilation_rate', (2, 2))75 conf = patch_config(conf, ['exit_flow/​block2/​unit1/​sepconv3_depthwise'], 'dilation_rate', (2, 2))76 patch = models.Model.from_config(conf)77 patch.set_weights(base.get_weights())78 return patch79AlignedXception71 = partial(80 wrap_bone,81 aligned_xception.Xception71,82 aligned_xception.preprocess_input)83def AlignedXception71Stride16(*args, **kwargs):84 base = AlignedXception71(*args, **kwargs)85 conf = base.get_config()86 conf = patch_config(conf, ['exit_flow/​block1/​unit1/​sepconv3_depthwise'], 'strides', (1, 1))87 conf = patch_config(conf, ['exit_flow/​block1/​unit1/​shortcut'], 'strides', (1, 1))88 conf = patch_config(conf, ['exit_flow/​block2/​unit1/​sepconv1_depthwise'], 'dilation_rate', (2, 2))89 conf = patch_config(conf, ['exit_flow/​block2/​unit1/​sepconv2_depthwise'], 'dilation_rate', (2, 2))90 conf = patch_config(conf, ['exit_flow/​block2/​unit1/​sepconv3_depthwise'], 'dilation_rate', (2, 2))91 patch = models.Model.from_config(conf)92 patch.set_weights(base.get_weights())93 return patch94def AlignedXception71Stride8(*args, **kwargs):95 base = AlignedXception71(*args, **kwargs)96 conf = base.get_config()97 conf = patch_config(conf, ['entry_flow/​block5/​unit1/​sepconv3_depthwise'], 'strides', (1, 1))98 conf = patch_config(conf, ['entry_flow/​block5/​unit1/​shortcut'], 'strides', (1, 1))99 for i in range(16):100 conf = patch_config(conf, [101 'middle_flow/​block1/​unit{}/​sepconv1_depthwise'.format(i + 1)], 'dilation_rate', (2, 2))102 conf = patch_config(conf, [103 'middle_flow/​block1/​unit{}/​sepconv2_depthwise'.format(i + 1)], 'dilation_rate', (2, 2))104 conf = patch_config(conf, [105 'middle_flow/​block1/​unit{}/​sepconv3_depthwise'.format(i + 1)], 'dilation_rate', (2, 2))106 conf = patch_config(conf, ['exit_flow/​block1/​unit1/​sepconv3_depthwise'], 'strides', (1, 1))107 conf = patch_config(conf, ['exit_flow/​block1/​unit1/​shortcut'], 'strides', (1, 1))108 # Output shape is different when using exit dilation rates like in109 # https:/​/​github.com/​bonlime/​keras-deeplab-v3-plus/​blob/​master/​model.py#L265110 conf = patch_config(conf, ['exit_flow/​block2/​unit1/​sepconv1_depthwise'], 'dilation_rate', (2, 2))111 conf = patch_config(conf, ['exit_flow/​block2/​unit1/​sepconv2_depthwise'], 'dilation_rate', (2, 2))112 conf = patch_config(conf, ['exit_flow/​block2/​unit1/​sepconv3_depthwise'], 'dilation_rate', (2, 2))113 patch = models.Model.from_config(conf)114 patch.set_weights(base.get_weights())...

Full Screen

Full Screen

luna_s3_p8.py

Source: luna_s3_p8.py Github

copy

Full Screen

1import data_transforms2import data_iterators3import pathfinder4import utils5import string6import numpy as np7import lasagne as nn8# IMPORT A CORRECT PATCH MODEL HERE9import lung_segmentation10import configs_seg_patch.luna_p8 as patch_config11# print utils.get_script_name(__file__).split('_')[-1]12# print patch_config.__name__.split('.')[-1]13# assert utils.get_script_name(__file__).replace('_s*_', '_') == patch_config.__name__.split('.')[-1]14rng = patch_config.rng15# calculate the following things correctly!16p_transform = {'patch_size': (416, 416, 416),17 'mm_patch_size': (416, 416, 416),18 'pixel_spacing': patch_config.p_transform['pixel_spacing']19 }20window_size = 16021stride = 12822n_windows = (p_transform['patch_size'][0] - window_size) /​ stride + 123valid_pids = patch_config.valid_pids24def data_prep_function(data, luna_annotations, pixel_spacing, luna_origin,25 p_transform=p_transform,26 p_transform_augment=None):27 # make sure the data is processed the same way28 lung_mask = lung_segmentation.segment_HU_scan(data)29 x, annotations_tf, tf_matrix, lung_mask_out = data_transforms.transform_scan3d(data=data,30 pixel_spacing=pixel_spacing,31 p_transform=p_transform,32 luna_annotations=luna_annotations,33 p_transform_augment=None,34 luna_origin=luna_origin,35 lung_mask=lung_mask)36 x = data_transforms.pixelnormHU(x)37 y = data_transforms.make_3d_mask_from_annotations(img_shape=x.shape, annotations=annotations_tf, shape='sphere')38 return x, y, lung_mask_out, annotations_tf, tf_matrix39valid_data_iterator = data_iterators.LunaScanPositiveLungMaskDataGenerator(data_path=pathfinder.LUNA_DATA_PATH,40 transform_params=p_transform,41 data_prep_fun=data_prep_function,42 rng=rng,43 batch_size=1,44 patient_ids=valid_pids,45 full_batch=True,46 random=False, infinite=False)47def build_model():48 metadata_dir = utils.get_dir_path('models', pathfinder.METADATA_PATH)49 metadata_path = utils.find_model_metadata(metadata_dir, patch_config.__name__.split('.')[-1])50 metadata = utils.load_pkl(metadata_path)51 print 'Build model'52 model = patch_config.build_model(patch_size=(window_size, window_size, window_size))53 all_layers = nn.layers.get_all_layers(model.l_out)54 num_params = nn.layers.count_params(model.l_out)55 print ' number of parameters: %d' % num_params56 print string.ljust(' layer output shapes:', 36),57 print string.ljust('#params:', 10),58 print 'output shape:'59 for layer in all_layers:60 name = string.ljust(layer.__class__.__name__, 32)61 num_param = sum([np.prod(p.get_value().shape) for p in layer.get_params()])62 num_param = string.ljust(num_param.__str__(), 10)63 print ' %s %s %s' % (name, num_param, layer.output_shape)64 nn.layers.set_all_param_values(model.l_out, metadata['param_values'])...

Full Screen

Full Screen

luna_s2_p8.py

Source: luna_s2_p8.py Github

copy

Full Screen

1import data_transforms2import data_iterators3import pathfinder4import utils5import string6import numpy as np7import lasagne as nn8# IMPORT A CORRECT PATCH MODEL HERE9import configs_seg_patch.luna_p8 as patch_config10# print utils.get_script_name(__file__).split('_')[-1]11# print patch_config.__name__.split('.')[-1]12# assert utils.get_script_name(__file__).replace('_s*_', '_') == patch_config.__name__.split('.')[-1]13rng = patch_config.rng14# calculate the following things correctly!15p_transform = {'patch_size': (416, 416, 416),16 'mm_patch_size': (416, 416, 416),17 'pixel_spacing': patch_config.p_transform['pixel_spacing']18 }19window_size = 16020stride = 12821n_windows = (p_transform['patch_size'][0] - window_size) /​ stride + 122valid_pids = patch_config.valid_pids23def data_prep_function(data, luna_annotations, pixel_spacing, luna_origin,24 p_transform=p_transform,25 p_transform_augment=None):26 # make sure the data is processed the same way 27 x, annotations_tf, tf_matrix = data_transforms.transform_scan3d(data=data,28 pixel_spacing=pixel_spacing,29 p_transform=p_transform,30 luna_annotations=luna_annotations,31 p_transform_augment=None,32 luna_origin=luna_origin)33 x = data_transforms.pixelnormHU(x)34 y = data_transforms.make_3d_mask_from_annotations(img_shape=x.shape, annotations=annotations_tf, shape='sphere')35 return x, y, annotations_tf, tf_matrix36valid_data_iterator = data_iterators.LunaScanPositiveDataGenerator(data_path=pathfinder.LUNA_DATA_PATH,37 transform_params=p_transform,38 data_prep_fun=data_prep_function,39 rng=rng,40 patient_ids=valid_pids,41 random=False, infinite=False)42def build_model():43 metadata_dir = utils.get_dir_path('models', pathfinder.METADATA_PATH)44 metadata_path = utils.find_model_metadata(metadata_dir, patch_config.__name__.split('.')[-1])45 metadata = utils.load_pkl(metadata_path)46 print 'Build model'47 model = patch_config.build_model(patch_size=(window_size, window_size, window_size))48 all_layers = nn.layers.get_all_layers(model.l_out)49 num_params = nn.layers.count_params(model.l_out)50 print ' number of parameters: %d' % num_params51 print string.ljust(' layer output shapes:', 36),52 print string.ljust('#params:', 10),53 print 'output shape:'54 for layer in all_layers:55 name = string.ljust(layer.__class__.__name__, 32)56 num_param = sum([np.prod(p.get_value().shape) for p in layer.get_params()])57 num_param = string.ljust(num_param.__str__(), 10)58 print ' %s %s %s' % (name, num_param, layer.output_shape)59 nn.layers.set_all_param_values(model.l_out, metadata['param_values'])...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Webinar: Move Forward With An Effective Test Automation Strategy [Voices of Community]

The key to successful test automation is to focus on tasks that maximize the return on investment (ROI), ensuring that you are automating the right tests and automating them in the right way. This is where test automation strategies come into play.

Dec’22 Updates: The All-New LT Browser 2.0, XCUI App Automation with HyperExecute, And More!

Greetings folks! With the new year finally upon us, we’re excited to announce a collection of brand-new product updates. At LambdaTest, we strive to provide you with a comprehensive test orchestration and execution platform to ensure the ultimate web and mobile experience.

Developers and Bugs – why are they happening again and again?

Entering the world of testers, one question started to formulate in my mind: “what is the reason that bugs happen?”.

Test Optimization for Continuous Integration

“Test frequently and early.” If you’ve been following my testing agenda, you’re probably sick of hearing me repeat that. However, it is making sense that if your tests detect an issue soon after it occurs, it will be easier to resolve. This is one of the guiding concepts that makes continuous integration such an effective method. I’ve encountered several teams who have a lot of automated tests but don’t use them as part of a continuous integration approach. There are frequently various reasons why the team believes these tests cannot be used with continuous integration. Perhaps the tests take too long to run, or they are not dependable enough to provide correct results on their own, necessitating human interpretation.

13 Best Java Testing Frameworks For 2023

The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.

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 yandex-tank 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