Spaces:
Build error
Build error
deploy: 74742225f881c53ee5a2d7f8a6f5c64fee2ff2ee
Browse files- layout-overlap.py +0 -5
layout-overlap.py
CHANGED
|
@@ -77,7 +77,6 @@ class LayoutOverlap(evaluate.Metric):
|
|
| 77 |
)
|
| 78 |
|
| 79 |
def __calculate_a1_ai(self, batch_bbox: npt.NDArray[np.float64]) -> A:
|
| 80 |
-
|
| 81 |
l1, t1, r1, b1 = convert_xywh_to_ltrb(batch_bbox[:, :, :, None])
|
| 82 |
l2, t2, r2, b2 = convert_xywh_to_ltrb(batch_bbox[:, :, None, :])
|
| 83 |
a1 = (r1 - l1) * (b1 - t1)
|
|
@@ -99,7 +98,6 @@ class LayoutOverlap(evaluate.Metric):
|
|
| 99 |
a1: npt.NDArray[np.float64],
|
| 100 |
batch_mask: npt.NDArray[np.bool_],
|
| 101 |
) -> npt.NDArray[np.float64]:
|
| 102 |
-
|
| 103 |
# shape: (B, S) -> (B, S, S)
|
| 104 |
batch_mask = ~batch_mask[:, None, :] | ~batch_mask[:, :, None]
|
| 105 |
indices = np.arange(S)
|
|
@@ -117,7 +115,6 @@ class LayoutOverlap(evaluate.Metric):
|
|
| 117 |
score_ac_layout_gan: npt.NDArray[np.float64],
|
| 118 |
batch_mask: npt.NDArray[np.bool_],
|
| 119 |
) -> npt.NDArray[np.float64]:
|
| 120 |
-
|
| 121 |
# shape: (B, S) -> (B,)
|
| 122 |
batch_mask = batch_mask.sum(axis=1)
|
| 123 |
|
|
@@ -130,7 +127,6 @@ class LayoutOverlap(evaluate.Metric):
|
|
| 130 |
def _compute_layout_gan(
|
| 131 |
self, S: int, B: int, ai: npt.NDArray[np.float64]
|
| 132 |
) -> npt.NDArray[np.float64]:
|
| 133 |
-
|
| 134 |
indices = np.arange(S)
|
| 135 |
ii, jj = np.meshgrid(indices, indices, indexing="ij")
|
| 136 |
|
|
@@ -149,7 +145,6 @@ class LayoutOverlap(evaluate.Metric):
|
|
| 149 |
bbox: Union[npt.NDArray[np.float64], List[List[int]]],
|
| 150 |
mask: Union[npt.NDArray[np.bool_], List[List[bool]]],
|
| 151 |
) -> Dict[str, npt.NDArray[np.float64]]:
|
| 152 |
-
|
| 153 |
# shape: (B, model_max_length, C)
|
| 154 |
bbox = np.array(bbox)
|
| 155 |
# shape: (B, model_max_length)
|
|
|
|
| 77 |
)
|
| 78 |
|
| 79 |
def __calculate_a1_ai(self, batch_bbox: npt.NDArray[np.float64]) -> A:
|
|
|
|
| 80 |
l1, t1, r1, b1 = convert_xywh_to_ltrb(batch_bbox[:, :, :, None])
|
| 81 |
l2, t2, r2, b2 = convert_xywh_to_ltrb(batch_bbox[:, :, None, :])
|
| 82 |
a1 = (r1 - l1) * (b1 - t1)
|
|
|
|
| 98 |
a1: npt.NDArray[np.float64],
|
| 99 |
batch_mask: npt.NDArray[np.bool_],
|
| 100 |
) -> npt.NDArray[np.float64]:
|
|
|
|
| 101 |
# shape: (B, S) -> (B, S, S)
|
| 102 |
batch_mask = ~batch_mask[:, None, :] | ~batch_mask[:, :, None]
|
| 103 |
indices = np.arange(S)
|
|
|
|
| 115 |
score_ac_layout_gan: npt.NDArray[np.float64],
|
| 116 |
batch_mask: npt.NDArray[np.bool_],
|
| 117 |
) -> npt.NDArray[np.float64]:
|
|
|
|
| 118 |
# shape: (B, S) -> (B,)
|
| 119 |
batch_mask = batch_mask.sum(axis=1)
|
| 120 |
|
|
|
|
| 127 |
def _compute_layout_gan(
|
| 128 |
self, S: int, B: int, ai: npt.NDArray[np.float64]
|
| 129 |
) -> npt.NDArray[np.float64]:
|
|
|
|
| 130 |
indices = np.arange(S)
|
| 131 |
ii, jj = np.meshgrid(indices, indices, indexing="ij")
|
| 132 |
|
|
|
|
| 145 |
bbox: Union[npt.NDArray[np.float64], List[List[int]]],
|
| 146 |
mask: Union[npt.NDArray[np.bool_], List[List[bool]]],
|
| 147 |
) -> Dict[str, npt.NDArray[np.float64]]:
|
|
|
|
| 148 |
# shape: (B, model_max_length, C)
|
| 149 |
bbox = np.array(bbox)
|
| 150 |
# shape: (B, model_max_length)
|