How to use get_region method in localstack

Best Python code snippet using localstack_python

pathology.py

Source:pathology.py Github

copy

Full Screen

1import tensorflow as tf2def get_region(image_tensor, h, w, position):3 if position == "left_upper":4 image_tensor = image_tensor[:, :h, :w, :]5 elif position == "right_upper":6 image_tensor = image_tensor[:, :h, w:, :]7 elif position == "left_lower":8 image_tensor = image_tensor[:, h:, :w, :]9 elif position == "right_lower":10 image_tensor = image_tensor[:, h:, w:, :]11 return image_tensor12def recon_overlapping_patches(image_tensor):13 # _, H, W, _ = image_tensor_concat.shape14 _, H, W, _ = image_tensor[0].shape15 h, w = H // 2, W // 216 # image_tensor = tf.split(image_tensor_concat, 10, -1)17 image_tensor_list = []18 row_0_col_0 = get_region(image_tensor[0], h, w, "left_upper") * 119 row_0_col_1 = get_region(image_tensor[0], h, w, "right_upper") * \20 0.5 + get_region(image_tensor[1], h, w, "left_upper") * 0.521 row_0_col_2 = get_region(image_tensor[1], h, w, "right_upper") * \22 0.5 + get_region(image_tensor[2], h, w, "left_upper") * 0.523 row_0_col_3 = get_region(image_tensor[2], h, w, "right_upper") * 124 row_1_col_0 = get_region(image_tensor[0], h, w, "left_lower") * \25 0.5 + get_region(image_tensor[3], h, w, "left_upper") * 0.526 row_1_col_1 = get_region(image_tensor[0], h, w, "right_lower") * 0.25 + get_region(image_tensor[1], h, w, "left_lower") * 0.25 + \27 get_region(image_tensor[3], h, w, "right_upper") * 0.25 + \28 get_region(image_tensor[4], h, w, "left_upper") * 0.2529 row_1_col_2 = get_region(image_tensor[1], h, w, "right_lower") * 0.25 + get_region(image_tensor[2], h, w, "left_lower") * 0.25 + \30 get_region(image_tensor[4], h, w, "right_upper") * 0.25 + \31 get_region(image_tensor[5], h, w, "left_upper") * 0.2532 row_1_col_3 = get_region(image_tensor[2], h, w, "right_lower") * \33 0.5 + get_region(image_tensor[5], h, w, "right_upper") * 0.534 row_2_col_0 = get_region(image_tensor[3], h, w, "left_lower") * \35 0.5 + get_region(image_tensor[6], h, w, "left_upper") * 0.536 row_2_col_1 = get_region(image_tensor[3], h, w, "right_lower") * 0.25 + get_region(image_tensor[4], h, w, "left_lower") * 0.25 + \37 get_region(image_tensor[6], h, w, "right_upper") * 0.25 + \38 get_region(image_tensor[7], h, w, "left_upper") * 0.2539 row_2_col_2 = get_region(image_tensor[4], h, w, "right_lower") * 0.25 + get_region(image_tensor[5], h, w, "left_lower") * 0.25 + \40 get_region(image_tensor[7], h, w, "right_upper") * 0.25 + \41 get_region(image_tensor[8], h, w, "left_upper") * 0.2542 row_2_col_3 = get_region(image_tensor[5], h, w, "right_lower") * \43 0.5 + get_region(image_tensor[8], h, w, "right_upper") * 0.544 row_3_col_0 = get_region(image_tensor[6], h, w, "left_lower") * 145 row_3_col_1 = get_region(image_tensor[6], h, w, "right_lower") * \46 0.5 + get_region(image_tensor[7], h, w, "left_lower") * 0.547 row_3_col_2 = get_region(image_tensor[7], h, w, "right_lower") * \48 0.5 + get_region(image_tensor[8], h, w, "left_lower") * 0.549 row_3_col_3 = get_region(image_tensor[8], h, w, "right_lower") * 150 image_tensor_list.append(row_0_col_0)51 image_tensor_list.append(row_0_col_1)52 image_tensor_list.append(row_0_col_2)53 image_tensor_list.append(row_0_col_3)54 image_tensor_list.append(row_1_col_0)55 image_tensor_list.append(row_1_col_1)56 image_tensor_list.append(row_1_col_2)57 image_tensor_list.append(row_1_col_3)58 image_tensor_list.append(row_2_col_0)59 image_tensor_list.append(row_2_col_1)60 image_tensor_list.append(row_2_col_2)61 image_tensor_list.append(row_2_col_3)62 image_tensor_list.append(row_3_col_0)63 image_tensor_list.append(row_3_col_1)64 image_tensor_list.append(row_3_col_2)65 image_tensor_list.append(row_3_col_3)66 row_1 = tf.concat(image_tensor_list[:4], axis=2)67 row_2 = tf.concat(image_tensor_list[4:8], axis=2)68 row_3 = tf.concat(image_tensor_list[8:12], axis=2)69 row_4 = tf.concat(image_tensor_list[12:], axis=2)70 restored = tf.concat([row_1, row_2, row_3, row_4], axis=1)71 return restored72# 1 / 4 Scale Restore73def recon_overlapping_patches_quarter_scale(image_tensor):74 # _, H, W, _ = image_tensor_concat.shape75 _, H, W, _ = image_tensor[0].shape76 h, w = H // 2, W // 277 col_in_row = 778 row_list = []79 col_list = []80 col_list.append(get_region(image_tensor[0], h, w, "left_upper") * 1)81 for idx in range(col_in_row - 1):82 col_element = get_region(image_tensor[idx], h, w, "right_upper") * \83 0.5 + get_region(image_tensor[idx + 1], h, w, "left_upper") * 0.584 col_list.append(col_element)85 col_list.append(get_region(86 image_tensor[col_in_row - 1], h, w, "right_upper") * 1)87 row_list.append(col_list)88 for row_idx in range(col_in_row - 1):89 start_num = row_idx * col_in_row90 col_list = []91 col_list.append(get_region(image_tensor[start_num], h, w, "left_lower") *92 0.5 + get_region(image_tensor[start_num + col_in_row], h, w, "left_upper") * 0.5)93 for col_idx in range(col_in_row - 1):94 col_element = get_region(image_tensor[start_num + col_idx], h, w, "right_lower") * 0.25 + \95 get_region(image_tensor[start_num + col_idx + 1], h, w, "left_lower") * 0.25 + \96 get_region(image_tensor[start_num + col_idx + col_in_row], h, w, "right_upper") * 0.25 + \97 get_region(image_tensor[start_num + col_idx + col_in_row + 1],98 h, w, "left_upper") * 0.2599 col_list.append(col_element)100 col_list.append(get_region(image_tensor[start_num + col_in_row - 1], h, w, "right_lower") *101 0.5 + get_region(image_tensor[start_num + col_in_row + col_in_row - 1], h, w, "right_upper") * 0.5)102 row_list.append(col_list)103 col_list = []104 start_num = (col_in_row - 1) * col_in_row105 col_list.append(get_region(106 image_tensor[start_num], h, w, "left_lower") * 1)107 for idx in range(col_in_row - 1):108 col_element = get_region(image_tensor[start_num + idx], h, w, "right_lower") * \109 0.5 + \110 get_region(image_tensor[start_num + idx + 1],111 h, w, "left_lower") * 0.5112 col_list.append(col_element)113 col_list.append(get_region(114 image_tensor[start_num + col_in_row - 1], h, w, "right_lower") * 1)115 row_list.append(col_list)116 row_list = [tf.concat(row, axis=2) for row in row_list]117 restored = tf.concat(row_list, axis=1)...

Full Screen

Full Screen

font_data.py

Source:font_data.py Github

copy

Full Screen

...3resource.path.append('res')45highlighted_font_image = resource.image('font.png')6Outlined = {7 "A" : [highlighted_font_image.get_region(0, 0, 25,25), 0, 0],8 "B" : [highlighted_font_image.get_region(25, 0, 25,25), 0, 0],9 "C" : [highlighted_font_image.get_region(50, 0, 25,25), 0, 0],10 "D" : [highlighted_font_image.get_region(75, 0, 25,25), 0, 0],11 "E" : [highlighted_font_image.get_region(99, 0, 26,25), 0, 0],12 "F" : [highlighted_font_image.get_region(125, 0, 25,25), 0, 0],13 "G" : [highlighted_font_image.get_region(150, 0, 25,25), 0, 0],14 "H" : [highlighted_font_image.get_region(175, 0, 25,25), 0, 0],15 "I" : [highlighted_font_image.get_region(206, 0, 12,25), 0, 0],16 "J" : [highlighted_font_image.get_region(225, 0, 25,25), 0, 0],17 "K" : [highlighted_font_image.get_region(250, 0, 25,25), 0, 0],18 "L" : [highlighted_font_image.get_region(275, 0, 22,25), 0, 0],19 "M" : [highlighted_font_image.get_region(300, 0, 25,25), 0, 0],20 "N" : [highlighted_font_image.get_region(325, 0, 25,25), 0, 0],21 "O" : [highlighted_font_image.get_region(349, 0, 27,26), 0, 0],22 "P" : [highlighted_font_image.get_region(375, 0, 25,25), 0, 0],23 "Q" : [highlighted_font_image.get_region(400, 0, 25,25), 0, 0],24 "R" : [highlighted_font_image.get_region(425, 0, 25,25), 0, 0],25 "S" : [highlighted_font_image.get_region(450, 0, 25,25), 0, 0],26 "T" : [highlighted_font_image.get_region(475, 0, 25,25), 0, 0],27 "U" : [highlighted_font_image.get_region(500, 0, 25,25), 0, 0],28 "V" : [highlighted_font_image.get_region(525, 0, 25,25), 0, 0],29 "W" : [highlighted_font_image.get_region(550, 0, 37,25), 0, 0],30 "X" : [highlighted_font_image.get_region(587, 0, 25,25), 0, 0],31 "Y" : [highlighted_font_image.get_region(614, 0, 23,25), 0, 0],32 "Z" : [highlighted_font_image.get_region(636, 0, 25,25), 0, 0],33 " " : [highlighted_font_image.get_region(660, 0, 15,25), 0, 0],34 35 #Lower-case36 "a" : [highlighted_font_image.get_region(2, 36, 17,25), 0, -1],37 "b" : [highlighted_font_image.get_region(27, 35, 19,28), 0, -3],38 "c" : [highlighted_font_image.get_region(53, 36, 17,25), 0, -1],39 "d" : [highlighted_font_image.get_region(77, 36, 19, 33), 0, -2],40 "e" : [highlighted_font_image.get_region(103, 36, 19, 33), 0, -1],41 "f" : [highlighted_font_image.get_region(130, 36, 14, 33), 0, -2],42 "g" : [highlighted_font_image.get_region(152, 32, 19, 39), 0, -4],43 "h" : [highlighted_font_image.get_region(177, 34, 18, 39), 0, -2],44 "i" : [highlighted_font_image.get_region(207, 32, 10, 39), 0, -3],45 "j" : [highlighted_font_image.get_region(231, 30, 9, 39), 0, -4],46 "k" : [highlighted_font_image.get_region(248, 33, 20, 34), 0, -3],47 "l" : [highlighted_font_image.get_region(284, 33, 7, 34), 0, -3],48 "m" : [highlighted_font_image.get_region(298, 33, 28, 24), 0, -2],49 "n" : [highlighted_font_image.get_region(328, 33, 18, 34), 0, -3],50 "o" : [highlighted_font_image.get_region(352, 33, 20, 34), 0, -3],51 "p" : [highlighted_font_image.get_region(376, 30, 19, 39), 0, -6],52 "q" : [highlighted_font_image.get_region(400, 30, 19, 39), 0, -6],53 "r" : [highlighted_font_image.get_region(429, 34, 12, 35), 0, -1],54 "s" : [highlighted_font_image.get_region(453, 34, 16, 35), 0, -1],55 "t" : [highlighted_font_image.get_region(479, 34, 16, 35), 0, -1],56 "u" : [highlighted_font_image.get_region(504, 34, 16, 35), 0, -1],57 "v" : [highlighted_font_image.get_region(527, 34, 18, 35), 0, -1],58 "w" : [highlighted_font_image.get_region(555, 34, 28, 35), 0, -1],59 "x" : [highlighted_font_image.get_region(591, 34, 18, 35), 0, -1],60 "y" : [highlighted_font_image.get_region(617, 30, 19, 39), 0, -7],61 "z" : [highlighted_font_image.get_region(642, 30, 18, 34), 0, -4.5],62 63 #Numbers64 "0" : [highlighted_font_image.get_region(4, 76, 21, 34), 0, -0.5],65 "1" : [highlighted_font_image.get_region(33, 76, 18, 35), 0, -0.5],66 "2" : [highlighted_font_image.get_region(59, 76, 19, 35), 0, -0.5],67 "3" : [highlighted_font_image.get_region(86, 76, 19, 35), 0, -0.5],68 "4" : [highlighted_font_image.get_region(112, 76, 21, 35), 0, -0.5],69 "5" : [highlighted_font_image.get_region(140, 76, 19, 35), 0, -0.5],70 "6" : [highlighted_font_image.get_region(167, 76, 19, 35), 0, -0.5],71 "7" : [highlighted_font_image.get_region(194, 76, 19, 35), 0, -0.5],72 "8" : [highlighted_font_image.get_region(220, 76, 20, 35), 0, -0.5],73 "9" : [highlighted_font_image.get_region(255, 76, 19, 35), 0, -0.5],74 75 #Special76 ":" : [highlighted_font_image.get_region(284, 76, 8, 35), 0, -0.5],77 "," : [highlighted_font_image.get_region(300, 70, 11, 35), -1, -5],78 "'" : [highlighted_font_image.get_region(354, 76, 6, 35), 0, -0.5],79 r'"' : [highlighted_font_image.get_region(370, 76, 12, 35), 0, -0.5],80 "." : [highlighted_font_image.get_region(319, 76, 8, 32), 0, -0.5],81 "?" : [highlighted_font_image.get_region(7, 112, 16, 32), 0, -0.5],82 "!" : [highlighted_font_image.get_region(35, 112, 8, 32), 0, -0.5], ...

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 localstack 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