Skip to content
Snippets Groups Projects

Updates for TREC pipelines

Merged Christopher Randolph Rhodes requested to merge int_trec into staging
2 files
+ 13
36
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -618,25 +618,6 @@ class RoiSet(object):
se[roi.Index] = oc
self.set_classification(f'classify_by_{name}', se)
def aggregate_classifications(self, query: str, name: str = 'aggregate'):
"""
Run query on DataFrame and put the results in a new boolean column
"""
cname = 'classify_by_' + name
if cname in self._df.columns:
raise DataFrameQueryError(f'Name {cname} is already used in RoiSet dataframe')
if self.count == 0:
self._df[cname] = None
return True
try:
self.set_classification(
cname,
self._df.eval(query)
)
except Exception as e:
raise DataFrameQueryError(e)
def get_instance_classification(self, roiset_from: Self, iou_min: float = 0.5) -> pd.DataFrame:
"""
@@ -671,10 +652,11 @@ class RoiSet(object):
return df_overlaps
def get_object_class_map(self, name: str) -> InMemoryDataAccessor:
def get_object_class_map(self, name: str, filter_by: Union[List, None] = None) -> InMemoryDataAccessor:
"""
For a given classification result, return a map where object IDs are replaced by each object's class
:param name: name of the classification result, same as passed to RoiSet.classify_by()
:param filter_by: only include ROIs if the intersection of all specified classifications is True
:return: accessor of object class map
"""
colname = ('classify_by_' + name)
@@ -684,8 +666,11 @@ class RoiSet(object):
def _label_object_class(roi):
om[self.acc_obj_ids.data == roi.label] = roi[colname]
self._df.apply(_label_object_class, axis=1)
if filter_by is None:
self._df.apply(_label_object_class, axis=1)
else:
pd_fil = self._df[[f'classify_by_{fb}' for fb in filter_by]]
self._df.loc[pd_fil.all(axis=1), :].apply(_label_object_class, axis=1)
return InMemoryDataAccessor(om)
def get_serializable_dataframe(self) -> pd.DataFrame:
Loading