File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11type : segmentation
22compatible_adaptation_types : ["frozen", "lora"]
33base_embeddings_folder : ${oc.env:THUNDER_BASE_DATA_FOLDER}/embeddings/
4+ no_bg_only_weight_test : 16.0
Original file line number Diff line number Diff line change @@ -664,14 +664,24 @@ def train_eval(
664664 for o , l in zip (all_out [i ], all_label )
665665 if len (l ) > 0
666666 ]
667- weights = [len (l ) for l in all_label if len (l ) > 0 ]
667+ weights = np .array ([len (l ) for l in all_label if len (l ) > 0 ]).astype (
668+ np .float32
669+ )
670+
671+ # Finding background-only masks
672+ bg_only = np .array ([l .sum ().item () == 0 for l in all_label ])
673+ freq_bg_only = bg_only .sum ().item () / len (bg_only )
674+ no_bg_only_weight = max (
675+ 1.0 , freq_bg_only * cfg .task .no_bg_only_weight_test
676+ )
677+ weights [~ bg_only ] *= no_bg_only_weight
668678
669- # Averagin per-image performance and computing confidence intervals
679+ # Averaging per-image performance and computing confidence intervals
670680 all_metrics_out = {}
671681 for key in all_metrics [0 ]:
672682 metric_vals = [d [key ]["metric_score" ] for d in all_metrics ]
673683 all_metrics_out [key ] = compute_metric (
674- weights ,
684+ weights . tolist () ,
675685 metric_vals ,
676686 lambda weights , metric_vals : np .average (
677687 metric_vals , weights = weights
You can’t perform that action at this time.
0 commit comments