211122-0905 detectron Instances initialization
Detectron’s Instances object gets created like this, creating attributes with names unknown initially:
def __init__(self, image_size: Tuple[int, int], **kwargs: Any):
    """
    Args:
        image_size (height, width): the spatial size of the image.
        kwargs: fields to add to this `Instances`.
    """
    self._image_size = image_size
    self._fields: Dict[str, Any] = {}
    for k, v in kwargs.items():
        self.set(k, v)
Which is neat.
To create an Instances object for unit tests I did:
pred_boxes = Boxes(tensor(
[
    [ 143.8892, 1166.6632, 1358.7292, 1411.6588],
    [ 131.3727,  864.3126, 1355.7804, 1144.3668],
    [ 585.6373,  747.7184,  922.6433,  815.9998]
]))
scores = tensor(
    [0.9971, 0.9967, 0.9938]
)
pred_classes = tensor([3, 3, 3])
instances = Instances(
    image_size=(2122, 1500),
    scores=scores,
    pred_classes=pred_classes,
    pred_boxes=pred_boxes
)
			
				
					Nel mezzo del deserto posso dire tutto quello che voglio.