o
    iC                     @  sP   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 G dd deZ
dS )	    )annotations)Callable)IgniteMetricHandler)PanopticQualityMetric)MetricReductionc                      s6   e Zd ZdZdejdddd dfd fddZ  ZS )PanopticQualityzv
    Computes Panoptic quality from full size Tensor and collects average over batch, class-channels, iterations.
    pqg      ?gư>c                 C  s   | S )N )xr	   r	   a/home/dell461/cl/sdc2/last_ska_mid/HISourceFinder-master-l/src/monai/handlers/panoptic_quality.py<lambda>!   s    zPanopticQuality.<lambda>Tnum_classesintmetric_namestr	reductionMetricReduction | strmatch_iou_thresholdfloatsmooth_numeratoroutput_transformr   save_detailsboolreturnNonec           	        s(   t |||||d}t j|||d dS )a  

        Args:
            num_classes: number of classes. The number should not count the background.
            metric_name: output metric. The value can be "pq", "sq" or "rq".
            reduction: define mode of reduction to the metrics, will only apply reduction on `not-nan` values,
                available reduction modes: {``"none"``, ``"mean"``, ``"sum"``, ``"mean_batch"``, ``"sum_batch"``,
                ``"mean_channel"``, ``"sum_channel"``}, default to `self.reduction`. if "none", will not do reduction.
            match_iou_threshold: IOU threshold to determine the pairing between `y_pred` and `y`. Usually,
                it should >= 0.5, the pairing between instances of `y_pred` and `y` are identical.
                If set `match_iou_threshold` < 0.5, this function uses Munkres assignment to find the
                maximal amount of unique pairing.
            smooth_numerator: a small constant added to the numerator to avoid zero.
            output_transform: callable to extract `y_pred` and `y` from `ignite.engine.state.output` then
                construct `(y_pred, y)` pair, where `y_pred` and `y` can be `batch-first` Tensors or
                lists of `channel-first` Tensors. the form of `(y_pred, y)` is required by the `update()`.
                `engine.state` and `output_transform` inherit from the ignite concept:
                https://pytorch.org/ignite/concepts.html#state, explanation and usage example are in the tutorial:
                https://github.com/Project-MONAI/tutorials/blob/master/modules/batch_output_transform.ipynb.
            save_details: whether to save metric computation details per image, for example: panoptic quality of
                every image.
                default to True, will save to `engine.state.metric_details` dict with the metric name as key.

        See also:
            :py:meth:`monai.metrics.panoptic_quality.compute_panoptic_quality`
        )r   r   r   r   r   )	metric_fnr   r   N)r   super__init__)	selfr   r   r   r   r   r   r   r   	__class__r	   r   r      s   $zPanopticQuality.__init__)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )__name__
__module____qualname____doc__r   
MEAN_BATCHr   __classcell__r	   r	   r   r   r      s    r   N)
__future__r   collections.abcr   monai.handlers.ignite_metricr   monai.metricsr   monai.utilsr   r   r	   r	   r	   r   <module>   s   