ravens/tasks/defs_cloth.py
def compute_pixel_IoU_coverage(self):
        """Computes IoU and coverage based on pixels.

        Use: `self.target_hull` and `self.current_hull`. For the former:
        values of 255 refer to the area contained within the zone (and
        includes the zone itself, FWIW). For the latter: segment to detect
        the workspace OR the zone ID. Then use numpy and/or operators:

        https://stackoverflow.com/questions/49338166/python-intersection-over-union
        https://stackoverflow.com/questions/14679595/vs-and-vs

        NOTE I: assumes cloth can be segmented by detecting the workspace and
        zone lines, and that any pixel OTHER than those belongs to cloth.

        NOTE II: IoU and coverage are computed in the same way, except that
        the former divides by the union, the latter divides by just the goal.
        """
        _, _, object_mask = self.get_object_masks(self.env)

        # Check object_mask for all pixels OTHER than the cloth.
        IDs = [1, self.zone_ID]  # 1 = workspace_ID
        mask = np.isin(object_mask, test_elements=IDs)

        # Flip items so that 1 = cloth (then 255 when scaled).
        idx_0s = (mask == 0)
        idx_1s = (mask == 1)
        mask[idx_0s] = 1
        mask[idx_1s] = 0
        cloth_mask_bool = np.array(mask, dtype=bool)

        # Compute pixel-wise IoU and coverage, using two bool dtype arrays.
        overlap        = self.target_hull_bool & cloth_mask_bool  # Logical AND
        union          = self.target_hull_bool | cloth_mask_bool  # Logical OR
        overlap_count  = np.count_nonzero(overlap)
        union_count    = np.count_nonzero(union)
        goal_count     = np.count_nonzero(self.target_hull_bool)
        pixel_IoU      = overlap_count / float(union_count)
        pixel_coverage = overlap_count / float(goal_count)
        return (pixel_IoU, pixel_coverage)
Computes IoU and coverage based on pixels.

        Use: `self.target_hull` and `self.current_hull`. For the former:
        values of 255 refer to the area contained within the zone (and
        includes the zone itself, FWIW). For the latter: segment to detect
        the workspace OR the zone ID. Then use numpy and/or operators:

        https://stackoverflow.com/questions/49338166/python-intersection-over-union
        https://stackoverflow.com/questions/14679595/vs-and-vs

        NOTE I: assumes cloth can be segmented by detecting the workspace and
        zone lines, and that any pixel OTHER than those belongs to cloth.

        NOTE II: IoU and coverage are computed in the same way, except that
        the former divides by the union, the latter divides by just the goal.
        
Computes IoU and coverage based on pixels.



NOTE I: assumes cloth can be segmented by detecting the workspace and
zone lines, and that any pixel OTHER than those belongs to cloth.

NOTE II: IoU and coverage are computed in the same way, except that
the former divides by the union, the latter divides by just the goal.
Computes IoU and coverage based on pixels . NOTE I : assumes cloth can be segmented by detecting the workspace and zone lines and that any pixel OTHER than those belongs to cloth . NOTE II : IoU and coverage are computed in the same way except that the former divides by the union the latter divides by just the goal .
def compute_pixel_IoU_coverage(self):
        _, _, object_mask = self.get_object_masks(self.env)
        IDs = [1, self.zone_ID]  
        mask = np.isin(object_mask, test_elements=IDs)
        idx_0s = (mask == 0)
        idx_1s = (mask == 1)
        mask[idx_0s] = 1
        mask[idx_1s] = 0
        cloth_mask_bool = np.array(mask, dtype=bool)
        overlap        = self.target_hull_bool & cloth_mask_bool  
        union          = self.target_hull_bool | cloth_mask_bool  
        overlap_count  = np.count_nonzero(overlap)
        union_count    = np.count_nonzero(union)
        goal_count     = np.count_nonzero(self.target_hull_bool)
        pixel_IoU      = overlap_count / float(union_count)
        pixel_coverage = overlap_count / float(goal_count)
        return (pixel_IoU, pixel_coverage)
def compute_pixel_IoU_coverage ( self ) : _ , _ , object_mask = self . get_object_masks ( self . env ) IDs = [ 1 , self . zone_ID ] mask = np . isin ( object_mask , test_elements = IDs ) idx_0s = ( mask == 0 ) idx_1s = ( mask == 1 ) mask [ idx_0s ] = 1 mask [ idx_1s ] = 0 cloth_mask_bool = np . array ( mask , dtype = bool ) overlap = self . target_hull_bool & cloth_mask_bool union = self . target_hull_bool | cloth_mask_bool overlap_count = np . count_nonzero ( overlap ) union_count = np . count_nonzero ( union ) goal_count = np . count_nonzero ( self . target_hull_bool ) pixel_IoU = overlap_count / float ( union_count ) pixel_coverage = overlap_count / float ( goal_count ) return ( pixel_IoU , pixel_coverage )
Computes IoU and coverage based on pixels.
Computes IoU and coverage based on pixels .
"""Computes IoU and coverage based on pixels.

        Use: `self.target_hull` and `self.current_hull`. For the former:
        values of 255 refer to the area contained within the zone (and
        includes the zone itself, FWIW). For the latter: segment to detect
        the workspace OR the zone ID. Then use numpy and/or operators:

        https://stackoverflow.com/questions/49338166/python-intersection-over-union
        https://stackoverflow.com/questions/14679595/vs-and-vs

        NOTE I: assumes cloth can be segmented by detecting the workspace and
        zone lines, and that any pixel OTHER than those belongs to cloth.

        NOTE II: IoU and coverage are computed in the same way, except that
        the former divides by the union, the latter divides by just the goal.
        """ # Check object_mask for all pixels OTHER than the cloth. # 1 = workspace_ID # Flip items so that 1 = cloth (then 255 when scaled). # Compute pixel-wise IoU and coverage, using two bool dtype arrays. # Logical AND # Logical OR
self