whylogs.extras.image_metric
#
Module Contents#
Classes#
Helper class that provides a standard way to create an ABC using |
|
MultiMetric serves as a base class for custom metrics that consist |
Functions#
|
Compute statistics data for a PIL Image |
|
Grab EXIF metadata from image |
|
|
|
Grab statistics data from a PIL ImageStats.Stat |
|
Initialize a DatasetSchema for logging images. This can be passed into a logger or why.log. |
|
Attributes#
- whylogs.extras.image_metric.logger#
- whylogs.extras.image_metric.ImageType#
- whylogs.extras.image_metric.get_pil_image_statistics(img: PIL.Image.Image, channels: List[str] = _IMAGE_HSV_CHANNELS, image_stats: List[str] = _STATS_PROPERTIES) Dict #
Compute statistics data for a PIL Image
- whylogs.extras.image_metric.get_pil_exif_metadata(img: PIL.Image.Image) Dict #
Grab EXIF metadata from image
- Parameters
img (ImageType) – PIL Image
- Returns
of metadata
- Return type
Dict
- whylogs.extras.image_metric.get_pil_image_metadata(img: PIL.Image.Image) Dict #
Grab statistics data from a PIL ImageStats.Stat
- Parameters
img (ImageType) – PIL Image
- Returns
of metadata
- Return type
Dict
- class whylogs.extras.image_metric.ImageSubmetricSchema#
Bases:
whylogs.core.metrics.multimetric.SubmetricSchema
Helper class that provides a standard way to create an ABC using inheritance.
- resolve(name: str, why_type: whylogs.core.datatypes.DataType, fi_disabled: bool = False) Dict[str, whylogs.core.metrics.metrics.Metric] #
- Parameters
name (str) –
why_type (whylogs.core.datatypes.DataType) –
fi_disabled (bool) –
- Return type
- class whylogs.extras.image_metric.ImageMetricConfig#
- class whylogs.extras.image_metric.ImageMetric(submetrics: Dict[str, Dict[str, whylogs.core.metrics.metrics.Metric]], allowed_exif_tags: Optional[Set[str]] = None, forbidden_exif_tags: Optional[Set[str]] = None, submetric_schema: Optional[whylogs.core.metrics.multimetric.SubmetricSchema] = None, type_mapper: Optional[whylogs.core.datatypes.TypeMapper] = None, fi_disabled: bool = False)#
Bases:
whylogs.core.metrics.multimetric.MultiMetric
MultiMetric serves as a base class for custom metrics that consist of one or more metrics. It is handy when you need to do some processing of the logged values and track several metrics on the results. The sub-metrics must either be a StandardMetric, or tagged as a @custom_metric or registered via register_metric(). Note that MultiMetric is neither, so it cannot be nested.
Typically you will need to override namespace(); columnar_update(), calling it on the submetrics as needed; and the zero() method to return an appropriate “empty” instance of your metric. You will need to override from_protobuf() and merge() if your subclass __init__() method takes arguments different than MultiMetrtic’s. You can use the submetrics_from_protbuf() and merge_submetrics() helper methods to implement them. The MultiMetric class will handle the rest of the Metric interface. Don’t use / or : in the subclass’ namespace.
See UnicodeRangeMetric for an example.
- Parameters
submetrics (Dict[str, Dict[str, whylogs.core.metrics.metrics.Metric]]) –
allowed_exif_tags (Optional[Set[str]]) –
forbidden_exif_tags (Optional[Set[str]]) –
submetric_schema (Optional[whylogs.core.metrics.multimetric.SubmetricSchema]) –
type_mapper (Optional[whylogs.core.datatypes.TypeMapper]) –
fi_disabled (bool) –
- submetrics: Dict[str, Dict[str, whylogs.core.metrics.Metric]]#
- merge(other: ImageMetric) ImageMetric #
- Parameters
other (ImageMetric) –
- Return type
- columnar_update(view: whylogs.core.preprocessing.PreprocessedColumn) whylogs.core.metrics.metrics.OperationResult #
- Parameters
- Return type
- classmethod zero(config: Optional[whylogs.core.metrics.metrics.MetricConfig] = None) ImageMetric #
- Parameters
config (Optional[whylogs.core.metrics.metrics.MetricConfig]) –
- Return type
- merge_submetrics(other: MULTI_METRIC) Dict[str, Dict[str, whylogs.core.metrics.Metric]] #
- Parameters
other (MULTI_METRIC) –
- Return type
Dict[str, Dict[str, whylogs.core.metrics.Metric]]
- to_protobuf() whylogs.core.proto.MetricMessage #
- Return type
whylogs.core.proto.MetricMessage
- to_summary_dict(cfg: Optional[whylogs.core.configs.SummaryConfig] = None) Dict[str, Any] #
- Parameters
cfg (Optional[whylogs.core.configs.SummaryConfig]) –
- Return type
Dict[str, Any]
- classmethod submetrics_from_protobuf(msg: whylogs.core.proto.MetricMessage) Dict[str, Dict[str, whylogs.core.metrics.Metric]] #
- Parameters
msg (whylogs.core.proto.MetricMessage) –
- Return type
Dict[str, Dict[str, whylogs.core.metrics.Metric]]
- classmethod from_protobuf(msg: whylogs.core.proto.MetricMessage) MULTI_METRIC #
- Parameters
msg (whylogs.core.proto.MetricMessage) –
- Return type
MULTI_METRIC
- classmethod get_namespace(config: Optional[MetricConfig] = None) str #
- Parameters
config (Optional[MetricConfig]) –
- Return type
- whylogs.extras.image_metric.init_image_schema(column_prefix: str = 'image') whylogs.core.schema.DatasetSchema #
Initialize a DatasetSchema for logging images. This can be passed into a logger or why.log.
- Parameters
column_prefix (str) – The prefix that appears in the dataset profiles along with all of the
"image" (image features. If the prefix is) – image_data}).
why.log({image (then you'll log image with) – image_data}).
- Return type
- whylogs.extras.image_metric.log_image(images: Union[PIL.Image.Image, List[PIL.Image.Image], Dict[str, PIL.Image.Image]], default_column_prefix: str = 'image', schema: Optional[whylogs.core.schema.DatasetSchema] = None, trace_id: Optional[str] = None) whylogs.api.logger.result_set.ResultSet #
- Parameters
images (Union[PIL.Image.Image, List[PIL.Image.Image], Dict[str, PIL.Image.Image]]) –
default_column_prefix (str) –
schema (Optional[whylogs.core.schema.DatasetSchema]) –
trace_id (Optional[str]) –
- Return type