Skip to content

Commit

Permalink
small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rabah-khalek committed Aug 13, 2024
1 parent 6575de5 commit 6dd32a1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
42 changes: 22 additions & 20 deletions giskard_vision/core/detectors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,21 @@ class ScanResult:
relative_delta: float
issue_group: Optional[IssueGroup] = None

def get_meta_required(self, add_slice_size=True) -> dict:
# Get the meta required by the original scan API
deviation = f"{self.relative_delta * 100:+.2f}% than global"
extra_meta = dict(slice_size=self.slice_size) if add_slice_size else dict()
return {
"metric": self.metric_name,
"metric_value": self.metric_value,
"metric_reference_value": self.metric_reference_value,
"deviation": deviation,
**extra_meta,
}

def get_meta_required(self, include_slice_size=True) -> dict:
deviation = f"{self.relative_delta * 100:+.2f}% than global"

meta_info = {
"metric": self.metric_name,
"metric_value": self.metric_value,
"metric_reference_value": self.metric_reference_value,
"deviation": deviation,
}

if include_slice_size:
meta_info["slice_size"] = self.slice_size

return meta_info


class DetectorVisionBase(DetectorSpecsBase):
Expand All @@ -65,8 +69,6 @@ class DetectorVisionBase(DetectorSpecsBase):
evaluation results for the scan.
"""

slicing: bool = True

def run(
self,
model: Any,
Expand Down Expand Up @@ -118,20 +120,20 @@ def get_issues(

for result in results:
if result.issue_level in issue_levels:
issue_attribute = (
dict(slicing_fn=result.name, meta=result.get_meta_required())
if self.slicing
else dict(transformation_fn=result.name, meta=result.get_meta_required(False))
)
extra_args = {
"slicing_fn" if self.slicing else "transformation_fn": result.name,
"meta": result.get_meta_required(self.slicing),
}

issues.append(
Issue(
model,
dataset,
level=result.issue_level,
group=result.issue_group if result.issue_group else self.issue_group,
group=result.issue_group or self.issue_group,
scan_examples=ImagesScanExamples(result.filename_examples, embed=embed),
display_footer_info=False,
**issue_attribute,
**extra_args,
)
)

Expand Down
1 change: 1 addition & 0 deletions giskard_vision/core/detectors/specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ class DetectorSpecsBase:
deviation_threshold: float = 0.10
issue_level_threshold: float = 0.05
num_images: int = 0
slicing: bool = True

0 comments on commit 6dd32a1

Please sign in to comment.