(self, height, width)
return bg_color, shapes
Creates random specifications of an image with multiple shapes.
        Returns the background color of the image and a list of shape
        specifications that can be used to draw the image.
Creates random specifications of an image with multiple shapes.
        Returns the background color of the image and a list of shape
        specifications that can be used to draw the image.
Creates random specifications of an image with multiple shapes . Returns the background color of the image and a list of shape specifications that can be used to draw the image .
def random_image(self, height, width):
        """Creates random specifications of an image with multiple shapes.
        Returns the background color of the image and a list of shape
        specifications that can be used to draw the image.
        """
        # Pick random background color
        bg_color = np.array([random.randint(0, 255) for _ in range(3)])
        # Generate a few random shapes and record their
        # bounding boxes
        shapes = []
        boxes = []
        N = random.randint(1, 4)
        for _ in range(N):
            shape, color, dims = self.random_shape(height, width)
            shapes.append((shape, color, dims))
            x, y, s = dims
            boxes.append([y-s, x-s, y+s, x+s])
        # Apply non-max suppression wit 0.3 threshold to avoid
        # shapes covering each other
        keep_ixs = utils.non_max_suppression(np.array(boxes), np.arange(N), 0.3)
        shapes = [s for i, s in enumerate(shapes) if i in keep_ixs]
        return bg_color, shapes
def random_image ( self , height , width ) : # Pick random background color bg_color = np . array ( [ random . randint ( 0 , 255 ) for _ in range ( 3 ) ] ) # Generate a few random shapes and record their # bounding boxes shapes = [ ] boxes = [ ] N = random . randint ( 1 , 4 ) for _ in range ( N ) : shape , color , dims = self . random_shape ( height , width ) shapes . append ( ( shape , color , dims ) ) x , y , s = dims boxes . append ( [ y - s , x - s , y + s , x + s ] ) # Apply non-max suppression wit 0.3 threshold to avoid # shapes covering each other keep_ixs = utils . non_max_suppression ( np . array ( boxes ) , np . arange ( N ) , 0.3 ) shapes = [ s for i , s in enumerate ( shapes ) if i in keep_ixs ] return bg_color , shapes