vision_unlearning.metrics.image =============================== .. py:module:: vision_unlearning.metrics.image Classes ------- .. autoapisummary:: vision_unlearning.metrics.image.MetricImage vision_unlearning.metrics.image.MetricPaintingStyle vision_unlearning.metrics.image.MetricRace vision_unlearning.metrics.image.MetricGender vision_unlearning.metrics.image.MetricQuality Module Contents --------------- .. py:class:: MetricImage(/, **data: Any) Bases: :py:obj:`vision_unlearning.metrics.base.Metric`, :py:obj:`abc.ABC` Based only on the image itself e.g., image quality, painting style .. py:method:: score(image: PIL.Image.Image) -> Dict[str, Any] :abstractmethod: .. py:class:: MetricPaintingStyle(/, **data: Any) Bases: :py:obj:`MetricImage` Based only on the image itself e.g., image quality, painting style .. py:attribute:: metrics :type: List[Literal['is_desired_style', 'desired_style_confidence']] :value: [] .. py:attribute:: desired_style :type: str .. py:attribute:: top_k :type: int :value: 5 .. py:attribute:: model_path :type: str .. py:attribute:: device :type: Optional[torch.device | str | int] :value: 'cuda' .. py:attribute:: _pipeline :type: Optional[transformers.pipelines.image_classification.ImageClassificationPipeline] :value: None .. py:method:: model_post_init(__context: Optional[dict] = None) -> None Override this method to perform additional initialization after `__init__` and `model_construct`. This is useful if you want to do some validation that requires the entire model to be initialized. .. py:method:: score(image: PIL.Image.Image) -> Dict[str, bool | float] .. py:class:: MetricRace(/, **data: Any) Bases: :py:obj:`MetricImage` Race classification using Hugging Face model: syntheticbot/clip-face-attribute-classifier Requires the following additional dependencies: * tf_keras = "~2.19.0" * tensorrt = "~10.13.2" * blinker = "~1.9.0" .. py:method:: model_post_init(__context: Optional[dict] = None) -> None Override this method to perform additional initialization after `__init__` and `model_construct`. This is useful if you want to do some validation that requires the entire model to be initialized. .. py:method:: score(image: PIL.Image.Image) -> Dict[str, str] .. py:class:: MetricGender(/, **data: Any) Bases: :py:obj:`MetricImage` Based only on the image itself e.g., image quality, painting style .. py:attribute:: device :type: Optional[torch.device | str | int] :value: 'cpu' .. py:attribute:: _model_name :type: str :value: 'prithivMLmods/Realistic-Gender-Classification' .. py:attribute:: _id2label .. py:attribute:: _model :type: Any .. py:attribute:: _processor :type: Any .. py:method:: model_post_init(__context) Override this method to perform additional initialization after `__init__` and `model_construct`. This is useful if you want to do some validation that requires the entire model to be initialized. .. py:method:: score(image: PIL.Image.Image) -> Dict[str, Union[Literal['male', 'female'], float]] .. py:class:: MetricQuality(/, **data: Any) Bases: :py:obj:`MetricImage` Based only on the image itself e.g., image quality, painting style .. py:method:: _load_image(img: Union[PIL.Image.Image, numpy.ndarray, str]) -> torch.Tensor .. py:method:: score(image: Union[PIL.Image.Image, numpy.ndarray, str]) -> Dict[str, float] .. py:method:: score_batch(images: List[Union[PIL.Image.Image, numpy.ndarray, str]]) -> List[Dict[str, float]]