franzi2505 commited on
Commit
64d9f33
1 Parent(s): 64af455

add method parameter to PanopticQuality + update readme

Browse files
Files changed (2) hide show
  1. PanopticQuality.py +5 -3
  2. README.md +7 -2
PanopticQuality.py CHANGED
@@ -12,7 +12,7 @@
12
  # See the License for the specific language governing permissions and
13
  # limitations under the License.
14
  """TODO: Add a description here."""
15
- from typing import Dict, List, Tuple
16
 
17
  import evaluate
18
  import datasets
@@ -86,7 +86,8 @@ class PQMetric(evaluate.Metric):
86
  (0**2, 6**2),
87
  (6**2, 12**2),
88
  (12**2, 1e5**2)],
89
- class_agnostic = False,
 
90
  **kwargs
91
  ):
92
  super().__init__(**kwargs)
@@ -144,7 +145,8 @@ class PQMetric(evaluate.Metric):
144
  stuffs=set([self.label2id[label] for label in self.label2id.keys() if label in self.stuff]),
145
  return_per_class=per_class,
146
  return_sq_and_rq=split_sq_rq,
147
- areas=area_rng
 
148
  )
149
  self.cont_to_cat = {label:key for key, label in self.pq_metric.metric.cat_id_to_continuous_id.items()}
150
 
 
12
  # See the License for the specific language governing permissions and
13
  # limitations under the License.
14
  """TODO: Add a description here."""
15
+ from typing import Dict, List, Tuple, Literal
16
 
17
  import evaluate
18
  import datasets
 
86
  (0**2, 6**2),
87
  (6**2, 12**2),
88
  (12**2, 1e5**2)],
89
+ method: Literal["iou", "hungarian"] = "iou",
90
+ class_agnostic: bool = False,
91
  **kwargs
92
  ):
93
  super().__init__(**kwargs)
 
145
  stuffs=set([self.label2id[label] for label in self.label2id.keys() if label in self.stuff]),
146
  return_per_class=per_class,
147
  return_sq_and_rq=split_sq_rq,
148
+ areas=area_rng,
149
+ method=method
150
  )
151
  self.cont_to_cat = {label:key for key, label in self.pq_metric.metric.cat_id_to_continuous_id.items()}
152
 
README.md CHANGED
@@ -179,7 +179,7 @@ Finished!
179
  ```
180
 
181
  ## Metric Settings
182
- The metric takes four optional input parameters: __label2id__, __stuff__, __per_class__ and __split_sq_rq__.
183
 
184
  * `label2id: Dict[str, int]`: this dictionary is used to map string labels to an integer representation.
185
  if not provided a default setting will be used:
@@ -215,7 +215,12 @@ The metric takes four optional input parameters: __label2id__, __stuff__, __per_
215
  * `area_rng: List[Tuple[float]]`: The list holds all the area ranges for which results are calculated.
216
  Each range is represented by a Tuple, where the first element is the lower limit and the second is the upper limit of the area range.
217
  Each value represents total number of pixels of a mask.
218
- The parameter defaults to [(0, 1e8)].
 
 
 
 
 
219
 
220
  ## Output Values
221
  A dictionary containing the following keys:
 
179
  ```
180
 
181
  ## Metric Settings
182
+ The metric takes four optional input parameters: __label2id__, __stuff__, __per_class__, __split_sq_rq__, __area_rng__, __class_agnostic__ and __method__.
183
 
184
  * `label2id: Dict[str, int]`: this dictionary is used to map string labels to an integer representation.
185
  if not provided a default setting will be used:
 
215
  * `area_rng: List[Tuple[float]]`: The list holds all the area ranges for which results are calculated.
216
  Each range is represented by a Tuple, where the first element is the lower limit and the second is the upper limit of the area range.
217
  Each value represents total number of pixels of a mask.
218
+ The parameter defaults to [(0, 1e5 ** 2),(0 ** 2, 6 ** 2),(6 ** 2, 12 ** 2),(12 ** 2, 1e5 ** 2)].
219
+ * `class_agnostic: bool = False`: If true, all instance labels will be merged to a single instance class (class agnostic), while semantic classes are preserved.
220
+ * `method: Litera["iou", "hungarian"] = "hungarian"`: Controls the method used to match predictions to ground truths.
221
+ If "iou", then a prediction is matched with a ground truth if IOU > 0.5 (https://arxiv.org/pdf/1801.00868). Can lead to unintuitive results.
222
+ If "hungarian", then predictions are matched with a ground truth by an hungarian optimizer, which allows also matches with 0 < iou <= 0.5 (https://arxiv.org/abs/2309.04887).
223
+ Both methods result in a one-to-one mapping.
224
 
225
  ## Output Values
226
  A dictionary containing the following keys: