vision_unlearning.benchmarks.I_care.utils ========================================= .. py:module:: vision_unlearning.benchmarks.I_care.utils .. autoapi-nested-parse:: Utility helpers for the I-CARE benchmark. - Image encoding/decoding (base64 PNG) - SHAP Explanation serialization (requires shap package — optional dep) - Error classes used across result templates Note: shap is imported lazily inside functions to avoid forcing all users to install it. It is only needed for the SHAP-related result templates. Exceptions ---------- .. autoapisummary:: vision_unlearning.benchmarks.I_care.utils.InvalidAttributeTypeError vision_unlearning.benchmarks.I_care.utils.InsufficientSamplesError Functions --------- .. autoapisummary:: vision_unlearning.benchmarks.I_care.utils._encode_image_file vision_unlearning.benchmarks.I_care.utils._decode_image vision_unlearning.benchmarks.I_care.utils.explanation_to_dict vision_unlearning.benchmarks.I_care.utils.dict_to_explanation Module Contents --------------- .. py:function:: _encode_image_file(img_path: str, max_dim: int = 1024) -> str Downsample / reduce resolution to limit size before encoding .. py:function:: _decode_image(image_data: str) -> io.BytesIO .. py:function:: explanation_to_dict(expl: Any) -> Dict[str, Any] Serialize a shap.Explanation to a plain dict (JSON-serializable). .. py:function:: dict_to_explanation(d: Dict[str, Any]) -> Any Deserialize a plain dict back to a shap.Explanation. Requires 'shap' package (optional dependency — install with pip install shap or pip install vision-unlearning[testbed]). .. py:exception:: InvalidAttributeTypeError Bases: :py:obj:`ValueError` Inappropriate argument value (of correct type). .. py:exception:: InsufficientSamplesError Bases: :py:obj:`ValueError` Inappropriate argument value (of correct type).