vision_unlearning.metrics.image

Classes

MetricImage

Based only on the image itself

MetricPaintingStyle

Based only on the image itself

MetricRace

Race classification using Hugging Face model:

MetricGender

Based only on the image itself

MetricQuality

Based only on the image itself

Module Contents

class vision_unlearning.metrics.image.MetricImage(/, **data: Any)[source]

Bases: vision_unlearning.metrics.base.Metric, abc.ABC

Based only on the image itself e.g., image quality, painting style

abstract score(image: PIL.Image.Image) Dict[str, Any][source]
class vision_unlearning.metrics.image.MetricPaintingStyle(/, **data: Any)[source]

Bases: MetricImage

Based only on the image itself e.g., image quality, painting style

metrics: List[Literal['is_desired_style', 'desired_style_confidence']] = []
desired_style: str
top_k: int = 5
model_path: str
device: torch.device | str | int | None = 'cuda'
_pipeline: transformers.pipelines.image_classification.ImageClassificationPipeline | None = None
model_post_init(__context: dict | None = None) None[source]

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.

score(image: PIL.Image.Image) Dict[str, bool | float][source]
class vision_unlearning.metrics.image.MetricRace(/, **data: Any)[source]

Bases: 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”

model_post_init(__context: dict | None = None) None[source]

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.

score(image: PIL.Image.Image) Dict[str, str][source]
class vision_unlearning.metrics.image.MetricGender(/, **data: Any)[source]

Bases: MetricImage

Based only on the image itself e.g., image quality, painting style

device: torch.device | str | int | None = 'cpu'
_model_name: str = 'prithivMLmods/Realistic-Gender-Classification'
_id2label
_model: Any
_processor: Any
model_post_init(__context)[source]

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.

score(image: PIL.Image.Image) Dict[str, Literal['male', 'female'] | float][source]
class vision_unlearning.metrics.image.MetricQuality(/, **data: Any)[source]

Bases: MetricImage

Based only on the image itself e.g., image quality, painting style

_load_image(img: PIL.Image.Image | numpy.ndarray | str) torch.Tensor[source]
score(image: PIL.Image.Image | numpy.ndarray | str) Dict[str, float][source]
score_batch(images: List[PIL.Image.Image | numpy.ndarray | str]) List[Dict[str, float]][source]