Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ada_verona/database/verification_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from pathlib import Path

import numpy as np
import pandas as pd

from ada_verona.database.dataset.data_point import DataPoint
Expand Down Expand Up @@ -87,6 +88,17 @@ def save_vnnlib_property(self, vnnlib_property: VNNLibProperty) -> None:
with open(save_path, "w") as f:
f.write(vnnlib_property.content)
vnnlib_property.path = save_path

# Optionally store additional metadata for verifiers that need direct access
# to the original image and class (e.g. SDP-CROWN).
if vnnlib_property.image is not None or vnnlib_property.image_class is not None:
meta_path = self.tmp_path / f"{vnnlib_property.name}.npz"
np.savez_compressed(
meta_path,
image=vnnlib_property.image,
image_class=-1 if vnnlib_property.image_class is None else vnnlib_property.image_class,
epsilon=-1.0 if vnnlib_property.epsilon is None else vnnlib_property.epsilon,
)

def delete_tmp_path(self) -> None:
"""
Expand Down
5 changes: 5 additions & 0 deletions ada_verona/database/vnnlib_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from dataclasses import dataclass
from pathlib import Path

import numpy as np


@dataclass
class VNNLibProperty:
Expand All @@ -24,3 +26,6 @@ class VNNLibProperty:
name: str
content: str
path: Path = None
epsilon: float | None = None
image: np.ndarray | None = None
image_class: int | None = None
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ def create_vnnlib_property(self, image: np.array, image_class: int, epsilon: flo

property_name = f"property_{image_class}_{str(epsilon).replace('.', '_')}"

return VNNLibProperty(name=property_name, content=result)
return VNNLibProperty(
name=property_name,
content=result,
epsilon=epsilon,
image=image,
image_class=image_class,
)

def get_dict_for_epsilon_result(self) -> dict:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ def create_vnnlib_property(self, image: np.array, image_class: int, epsilon: flo

property_name = f"property_{image_class}_{str(epsilon).replace('.', '_')}"

return VNNLibProperty(name=property_name, content=result)
return VNNLibProperty(
name=property_name,
content=result,
epsilon=epsilon,
image=image,
image_class=image_class,
)

def get_dict_for_epsilon_result(self) -> dict:
"""
Expand Down