How to use remove_kernel method in autotest

Best Python code snippet using autotest_python

utils.py

Source:utils.py Github

copy

Full Screen

1import cv22import numpy as np3import torchvision4import torch5def segment(model, x):6 model = model.eval()7 x = cv2.resize(x, (512, 1024))8 x = torchvision.transforms.ToTensor()(x).unsqueeze(0)9 with torch.no_grad():10 x = model(x)11 mask = x[0, 0]12 height = x[0, 1]13 mask = (mask > 0).numpy().astype(np.uint8, copy=False) * 25514 height = height.numpy()15 np.exp(height, out=height)16 height = np.rint(height)17 height = height.astype(np.int, copy=False)18 return mask, height19def detect_lines(x, hmap, im_size):20 fx = im_size[1] / x.shape[1]21 fy = im_size[0] / x.shape[0]22 connect_kernel = np.ones((1, 30 + 1), dtype=np.uint8)23 remove_kernel = np.ones((1, 10 + 1), dtype=np.uint8)24 cv2.dilate(x, connect_kernel, x)25 cv2.erode(x, connect_kernel, x)26 # remove short lines27 cv2.erode(x, remove_kernel, x)28 cv2.dilate(x, remove_kernel, x)29 num_line, segment_lines = cv2.connectedComponents(x)30 boxes = []31 for c in range(num_line):32 line = segment_lines == c33 x = np.sum(line, axis=0)34 x = np.nonzero(x)[0]35 x1, x2 = x[0], x[-1]36 y = np.argmax(line, axis=0)37 y2 = max(y[x1], y[x2])38 h = np.mean(hmap[line])39 h = h + abs(y[x1] - y[x2])40 y1 = max(y2 - h, 0)41 if y2 == 0:42 continue43 boxes.append([44 (int(round(x1*fx)), int(round(y1*fy))),45 (int(round(x2*fx)), int(round(y2*fy)))46 ])...

Full Screen

Full Screen

rm_kernel.py

Source:rm_kernel.py Github

copy

Full Screen

...24 # console init25 console = Console()26 # load config27 config = Config()...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

...9 return {"free":"NO_MACHINE"}10 item=[free_list[0]]11 print("item is")12 print(item)13 remove_kernel(item[0].split(":")[0],item[0].split(":")[1],item[0].split(":")[2],item[0].split(":")[3])14 return {"free":item}15@app.route("/service_registry/get_service_location/<service>")16def get_service_location(service):17 return {"location":service_registry[service]};18def remove_kernel(ip,username,password,port):19 free_list.remove(str(ip)+":"+str(username)+":"+str(password)+":"+str(port));20if __name__ == "__main__": # on running python app.py...

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