How to use test_image method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

visualization_utils_test.py

Source:visualization_utils_test.py Github

copy

Full Screen

...20import PIL.Image as Image21import tensorflow as tf22from object_detection.utils import visualization_utils23class VisualizationUtilsTest(tf.test.TestCase):24 def create_colorful_test_image(self):25 """This function creates an image that can be used to test vis functions.26 It makes an image composed of four colored rectangles.27 Returns:28 colorful test numpy array image.29 """30 ch255 = np.full([100, 200, 1], 255, dtype=np.uint8)31 ch128 = np.full([100, 200, 1], 128, dtype=np.uint8)32 ch0 = np.full([100, 200, 1], 0, dtype=np.uint8)33 imr = np.concatenate((ch255, ch128, ch128), axis=2)34 img = np.concatenate((ch255, ch255, ch0), axis=2)35 imb = np.concatenate((ch255, ch0, ch255), axis=2)36 imw = np.concatenate((ch128, ch128, ch128), axis=2)37 imu = np.concatenate((imr, img), axis=1)38 imd = np.concatenate((imb, imw), axis=1)39 image = np.concatenate((imu, imd), axis=0)40 return image41 def test_draw_bounding_box_on_image(self):42 test_image = self.create_colorful_test_image()43 test_image = Image.fromarray(test_image)44 width_original, height_original = test_image.size45 ymin = 0.2546 ymax = 0.7547 xmin = 0.448 xmax = 0.649 visualization_utils.draw_bounding_box_on_image(test_image, ymin, xmin, ymax,50 xmax)51 width_final, height_final = test_image.size52 self.assertEqual(width_original, width_final)53 self.assertEqual(height_original, height_final)54 def test_draw_bounding_box_on_image_array(self):55 test_image = self.create_colorful_test_image()56 width_original = test_image.shape[0]57 height_original = test_image.shape[1]58 ymin = 0.2559 ymax = 0.7560 xmin = 0.461 xmax = 0.662 visualization_utils.draw_bounding_box_on_image_array(63 test_image, ymin, xmin, ymax, xmax)64 width_final = test_image.shape[0]65 height_final = test_image.shape[1]66 self.assertEqual(width_original, width_final)67 self.assertEqual(height_original, height_final)68 def test_draw_bounding_boxes_on_image(self):69 test_image = self.create_colorful_test_image()70 test_image = Image.fromarray(test_image)71 width_original, height_original = test_image.size72 boxes = np.array([[0.25, 0.75, 0.4, 0.6],73 [0.1, 0.1, 0.9, 0.9]])74 visualization_utils.draw_bounding_boxes_on_image(test_image, boxes)75 width_final, height_final = test_image.size76 self.assertEqual(width_original, width_final)77 self.assertEqual(height_original, height_final)78 def test_draw_bounding_boxes_on_image_array(self):79 test_image = self.create_colorful_test_image()80 width_original = test_image.shape[0]81 height_original = test_image.shape[1]82 boxes = np.array([[0.25, 0.75, 0.4, 0.6],83 [0.1, 0.1, 0.9, 0.9]])84 visualization_utils.draw_bounding_boxes_on_image_array(test_image, boxes)85 width_final = test_image.shape[0]86 height_final = test_image.shape[1]87 self.assertEqual(width_original, width_final)88 self.assertEqual(height_original, height_final)89 def test_draw_keypoints_on_image(self):90 test_image = self.create_colorful_test_image()91 test_image = Image.fromarray(test_image)92 width_original, height_original = test_image.size93 keypoints = [[0.25, 0.75], [0.4, 0.6], [0.1, 0.1], [0.9, 0.9]]94 visualization_utils.draw_keypoints_on_image(test_image, keypoints)95 width_final, height_final = test_image.size96 self.assertEqual(width_original, width_final)97 self.assertEqual(height_original, height_final)98 def test_draw_keypoints_on_image_array(self):99 test_image = self.create_colorful_test_image()100 width_original = test_image.shape[0]101 height_original = test_image.shape[1]102 keypoints = [[0.25, 0.75], [0.4, 0.6], [0.1, 0.1], [0.9, 0.9]]103 visualization_utils.draw_keypoints_on_image_array(test_image, keypoints)104 width_final = test_image.shape[0]105 height_final = test_image.shape[1]106 self.assertEqual(width_original, width_final)107 self.assertEqual(height_original, height_final)108 def test_draw_mask_on_image_array(self):109 test_image = np.asarray([[[0, 0, 0], [0, 0, 0]],110 [[0, 0, 0], [0, 0, 0]]], dtype=np.uint8)111 mask = np.asarray([[0.0, 1.0],112 [1.0, 1.0]], dtype=np.float32)113 expected_result = np.asarray([[[0, 0, 0], [0, 0, 127]],...

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