์ฝ˜ํ…์ธ ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

์ฐธ์กฐ ultralytics/models/nas/val.py

์ฐธ๊ณ 

์ด ํŒŒ์ผ์€ https://github.com/ultralytics/ ultralytics/blob/main/ ultralytics/models/nas/val .py์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฌธ์ œ๋ฅผ ๋ฐœ๊ฒฌํ•˜๋ฉด ํ’€ ๋ฆฌํ€˜์ŠคํŠธ (๐Ÿ› ๏ธ)๋ฅผ ์ œ์ถœํ•˜์—ฌ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋„๋ก ๋„์™€์ฃผ์„ธ์š”. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค ๐Ÿ™!



ultralytics.models.nas.val.NASValidator

๊ธฐ์ง€: DetectionValidator

Ultralytics YOLO ๊ฐ์ฒด ๊ฐ์ง€๋ฅผ ์œ„ํ•œ NAS ๊ฒ€์ฆ๊ธฐ.

ํ™•์žฅ DetectionValidator Ultralytics ๋ชจ๋ธ ํŒจํ‚ค์ง€์—์„œ ์ƒ์„ฑ๋œ ์›์‹œ ์˜ˆ์ธก์„ ํ›„์ฒ˜๋ฆฌํ•˜๋„๋ก ์„ค๊ณ„๋˜์—ˆ์Šต๋‹ˆ๋‹ค. YOLO ์›์‹œ ์˜ˆ์ธก์„ ํ›„์ฒ˜๋ฆฌํ•˜๋„๋ก ์„ค๊ณ„๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋น„์ตœ๋Œ€ ์–ต์ œ๋ฅผ ์ˆ˜ํ–‰ํ•˜์—ฌ ์ค‘๋ณต ๋ฐ ์‹ ๋ขฐ๋„๊ฐ€ ๋‚ฎ์€ ๋ฐ•์Šค๋ฅผ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค, ๊ถ๊ทน์ ์œผ๋กœ ์ตœ์ข… ํƒ์ง€ ๊ฒฐ๊ณผ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

์†์„ฑ:

์ด๋ฆ„ ์œ ํ˜• ์„ค๋ช…
args Namespace

์‹ ๋ขฐ๋„ ๋ฐ IoU ์ž„๊ณ„๊ฐ’ ๋“ฑ ์‚ฌํ›„ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ๋‹ค์–‘ํ•œ ๊ตฌ์„ฑ์ด ํฌํ•จ๋œ ๋„ค์ž„์ŠคํŽ˜์ด์Šค์ž…๋‹ˆ๋‹ค.

lb Tensor

๋ฉ€ํ‹ฐ๋ ˆ์ด๋ธ” NMS์˜ ๊ฒฝ์šฐ tensor (์˜ต์…˜).

์˜ˆ์ œ
from ultralytics import NAS

model = NAS('yolo_nas_s')
validator = model.validator
# Assumes that raw_preds are available
final_preds = validator.postprocess(raw_preds)
์ฐธ๊ณ 

์ด ํด๋ž˜์Šค๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ ์ง์ ‘ ์ธ์Šคํ„ด์Šคํ™”๋˜์ง€ ์•Š๊ณ  ๋‚ด๋ถ€์ ์œผ๋กœ NAS ํด๋ž˜์Šค.

์˜ ์†Œ์Šค ์ฝ”๋“œ ultralytics/models/nas/val.py
class NASValidator(DetectionValidator):
    """
    Ultralytics YOLO NAS Validator for object detection.

    Extends `DetectionValidator` from the Ultralytics models package and is designed to post-process the raw predictions
    generated by YOLO NAS models. It performs non-maximum suppression to remove overlapping and low-confidence boxes,
    ultimately producing the final detections.

    Attributes:
        args (Namespace): Namespace containing various configurations for post-processing, such as confidence and IoU thresholds.
        lb (torch.Tensor): Optional tensor for multilabel NMS.

    Example:
        ```python
        from ultralytics import NAS

        model = NAS('yolo_nas_s')
        validator = model.validator
        # Assumes that raw_preds are available
        final_preds = validator.postprocess(raw_preds)
        ```

    Note:
        This class is generally not instantiated directly but is used internally within the `NAS` class.
    """

    def postprocess(self, preds_in):
        """Apply Non-maximum suppression to prediction outputs."""
        boxes = ops.xyxy2xywh(preds_in[0][0])
        preds = torch.cat((boxes, preds_in[0][1]), -1).permute(0, 2, 1)
        return ops.non_max_suppression(
            preds,
            self.args.conf,
            self.args.iou,
            labels=self.lb,
            multi_label=False,
            agnostic=self.args.single_cls,
            max_det=self.args.max_det,
            max_time_img=0.5,
        )

postprocess(preds_in)

์˜ˆ์ธก ์ถœ๋ ฅ์— ์ตœ๋Œ€๊ฐ’์ด ์•„๋‹Œ ์–ต์ œ๋ฅผ ์ ์šฉํ•ฉ๋‹ˆ๋‹ค.

์˜ ์†Œ์Šค ์ฝ”๋“œ ultralytics/models/nas/val.py
def postprocess(self, preds_in):
    """Apply Non-maximum suppression to prediction outputs."""
    boxes = ops.xyxy2xywh(preds_in[0][0])
    preds = torch.cat((boxes, preds_in[0][1]), -1).permute(0, 2, 1)
    return ops.non_max_suppression(
        preds,
        self.args.conf,
        self.args.iou,
        labels=self.lb,
        multi_label=False,
        agnostic=self.args.single_cls,
        max_det=self.args.max_det,
        max_time_img=0.5,
    )





์ƒ์„ฑ๋จ 2023-11-12, ์—…๋ฐ์ดํŠธ๋จ 2023-11-25
์ž‘์„ฑ์ž: glenn-jocher (3)