(self, polygons, size)
Arguments:
            polygons:
                a list of list of lists of numbers. The first
                level of the list correspond to individual instances,
                the second level to all the polygons that compose the
                object, and the third level to the polygon coordinates.

                OR

                a list of PolygonInstances.

                OR

                a PolygonList

            size: absolute image size
Arguments:
            polygons:
                a list of list of lists of numbers. The first
                level of the list correspond to individual instances,
                the second level to all the polygons that compose the
                object, and the third level to the polygon coordinates.
Arguments : polygons : a list of list of lists of numbers . The first level of the list correspond to individual instances the second level to all the polygons that compose the object and the third level to the polygon coordinates .
def __init__(self, polygons, size):
        """
        Arguments:
            polygons:
                a list of list of lists of numbers. The first
                level of the list correspond to individual instances,
                the second level to all the polygons that compose the
                object, and the third level to the polygon coordinates.

                OR

                a list of PolygonInstances.

                OR

                a PolygonList

            size: absolute image size

        """
        if isinstance(polygons, (list, tuple)):
            if len(polygons) == 0:
                polygons = [[[]]]
            if isinstance(polygons[0], (list, tuple)):
                assert isinstance(polygons[0][0], (list, tuple)), str(
                    type(polygons[0][0])
                )
            else:
                assert isinstance(polygons[0], PolygonInstance), str(type(polygons[0]))

        elif isinstance(polygons, PolygonList):
            size = polygons.size
            polygons = polygons.polygons

        else:
            RuntimeError(
                "Type of argument `polygons` is not allowed:%s" % (type(polygons))
            )

        assert isinstance(size, (list, tuple)), str(type(size))

        self.polygons = []
        for p in polygons:
            p = PolygonInstance(p, size)
            if len(p) > 0:
                self.polygons.append(p)

        self.size = tuple(size)
def __init__ ( self , polygons , size ) : if isinstance ( polygons , ( list , tuple ) ) : if len ( polygons ) == 0 : polygons = [ [ [ ] ] ] if isinstance ( polygons [ 0 ] , ( list , tuple ) ) : assert isinstance ( polygons [ 0 ] [ 0 ] , ( list , tuple ) ) , str ( type ( polygons [ 0 ] [ 0 ] ) ) else : assert isinstance ( polygons [ 0 ] , PolygonInstance ) , str ( type ( polygons [ 0 ] ) ) elif isinstance ( polygons , PolygonList ) : size = polygons . size polygons = polygons . polygons else : RuntimeError ( "Type of argument `polygons` is not allowed:%s" % ( type ( polygons ) ) ) assert isinstance ( size , ( list , tuple ) ) , str ( type ( size ) ) self . polygons = [ ] for p in polygons : p = PolygonInstance ( p , size ) if len ( p ) > 0 : self . polygons . append ( p ) self . size = tuple ( size )