μ½˜ν…μΈ λ‘œ κ±΄λ„ˆλ›°κΈ°

κ³ κΈ‰ μ‚¬μš©μž 지정

Ultralytics YOLO λͺ…령쀄과 Python μΈν„°νŽ˜μ΄μŠ€λŠ” λͺ¨λ‘ κΈ°λ³Έ 엔진 싀행기에 λŒ€ν•œ 높은 μˆ˜μ€€μ˜ 좔상화일 λΏμž…λ‹ˆλ‹€. νŠΈλ ˆμ΄λ„ˆ 엔진을 μ‚΄νŽ΄λ³΄κ² μŠ΅λ‹ˆλ‹€.



Watch: Mastering Ultralytics YOLO: Advanced Customization

베이슀 νŠΈλ ˆμ΄λ„ˆ

베이슀 νŠΈλ ˆμ΄λ„ˆμ—λŠ” 일반적인 μƒμš©κ΅¬ νŠΈλ ˆμ΄λ‹ 루틴이 ν¬ν•¨λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. μ˜¬λ°”λ₯Έ ν˜•μ‹μ„ λ”°λ₯΄κΈ°λ§Œ ν•˜λ©΄ ν•„μš”ν•œ ν•¨μˆ˜λ‚˜ 연산을 μž¬μ •μ˜ν•˜μ—¬ λͺ¨λ“  μž‘μ—…μ— 맞게 μ‚¬μš©μž 지정할 수 μžˆμŠ΅λ‹ˆλ‹€. 예λ₯Ό λ“€μ–΄, μ΄λŸ¬ν•œ ν•¨μˆ˜λ₯Ό μž¬μ •μ˜ν•˜μ—¬ μ‚¬μš©μž 지정 λͺ¨λΈκ³Ό 데이터 λ‘œλ”λ₯Ό 지원할 수 μžˆμŠ΅λ‹ˆλ‹€:

  • get_model(cfg, weights) - ν•™μŠ΅ν•  λͺ¨λΈμ„ κ΅¬μΆ•ν•˜λŠ” ν•¨μˆ˜
  • get_dataloader() - λ°μ΄ν„°λ‘œλ”λ₯Ό λΉŒλ“œν•˜λŠ” ν•¨μˆ˜ μžμ„Έν•œ λ‚΄μš©κ³Ό μ†ŒμŠ€ μ½”λ“œλŠ” λ‹€μŒμ—μ„œ 확인할 수 μžˆμŠ΅λ‹ˆλ‹€. BaseTrainer μ°Έμ‘°

탐지 νŠΈλ ˆμ΄λ„ˆ

Here's how you can use the YOLO11 DetectionTrainer λ₯Ό ν΄λ¦­ν•˜κ³  μ‚¬μš©μž μ§€μ •ν•©λ‹ˆλ‹€.

from ultralytics.models.yolo.detect import DetectionTrainer

trainer = DetectionTrainer(overrides={...})
trainer.train()
trained_model = trainer.best  # get best model

탐지 νŠΈλ ˆμ΄λ„ˆ μ‚¬μš©μž 지정

νŠΈλ ˆμ΄λ„ˆλ₯Ό 맞좀 μ„€μ •ν•΄ λ³΄κ² μŠ΅λ‹ˆλ‹€. 을 μ‚¬μš©ν•˜μ—¬ μ‚¬μš©μž 지정 탐지 λͺ¨λΈμ„ ν•™μŠ΅ν•©λ‹ˆλ‹€. λ₯Ό 직접 μ§€μ›ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. 이 μž‘μ—…μ„ μˆ˜ν–‰ν•˜λ €λ©΄ κΈ°μ‘΄ the get_model κΈ°λŠ₯을 μ œκ³΅ν•©λ‹ˆλ‹€:

from ultralytics.models.yolo.detect import DetectionTrainer


class CustomTrainer(DetectionTrainer):
    def get_model(self, cfg, weights):
        """Loads a custom detection model given configuration and weight files."""
        ...


trainer = CustomTrainer(overrides={...})
trainer.train()

이제 νŠΈλ ˆμ΄λ„ˆλ₯Ό 더 μ‚¬μš©μž 지정해야 ν•œλ‹€λŠ” 것을 μ•Œκ²Œ λ˜μ—ˆμŠ΅λ‹ˆλ‹€:

  • μ‚¬μš©μž 지정 loss function.
  • μΆ”κ°€ callback 맀 10μ΄ˆλ§ˆλ‹€ Google λ“œλΌμ΄λΈŒμ— λͺ¨λΈμ„ μ—…λ‘œλ“œν•©λ‹ˆλ‹€. epochs 방법은 λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€:
from ultralytics.models.yolo.detect import DetectionTrainer
from ultralytics.nn.tasks import DetectionModel


class MyCustomModel(DetectionModel):
    def init_criterion(self):
        """Initializes the loss function and adds a callback for uploading the model to Google Drive every 10 epochs."""
        ...


class CustomTrainer(DetectionTrainer):
    def get_model(self, cfg, weights):
        """Returns a customized detection model instance configured with specified config and weights."""
        return MyCustomModel(...)


# callback to upload model weights
def log_model(trainer):
    """Logs the path of the last model weight used by the trainer."""
    last_weight_path = trainer.last
    print(last_weight_path)


trainer = CustomTrainer(overrides={...})
trainer.add_callback("on_train_epoch_end", log_model)  # Adds to existing callback
trainer.train()

콜백 트리거 이벀트 및 μ§„μž… 지점에 λŒ€ν•œ μžμ„Έν•œ λ‚΄μš©μ€ 콜백 κ°€μ΄λ“œλ₯Ό ν™•μΈν•˜μ„Έμš”.

기타 엔진 ꡬ성 μš”μ†Œ

λ‹€μŒκ³Ό 같이 μœ μ‚¬ν•˜κ²Œ μ‚¬μš©μž 지정할 수 μžˆλŠ” λ‹€λ₯Έ ꡬ성 μš”μ†Œλ„ μžˆμŠ΅λ‹ˆλ‹€. Validators 그리고 Predictors. 이에 λŒ€ν•œ μžμ„Έν•œ λ‚΄μš©μ€ μ°Έμ‘° μ„Ήμ…˜μ„ μ°Έμ‘°ν•˜μ„Έμš”.

자주 λ¬»λŠ” 질문

How do I customize the Ultralytics YOLO11 DetectionTrainer for specific tasks?

To customize the Ultralytics YOLO11 DetectionTrainer 의 λ©”μ„œλ“œλ₯Ό μž¬μ •μ˜ν•˜μ—¬ μ‚¬μš©μž μ •μ˜ λͺ¨λΈ 및 데이터 λ‘œλ”μ— 맞게 μ‘°μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€. λ¨Όμ € λ‹€μŒμ—μ„œ 상속을 μ‹œμž‘ν•˜μ„Έμš”. DetectionTrainer 와 같은 λ©”μ„œλ“œλ₯Ό μž¬μ •μ˜ν•œ λ‹€μŒ get_model λ₯Ό μ‚¬μš©ν•˜μ—¬ μ‚¬μš©μž 지정 κΈ°λŠ₯을 κ΅¬ν˜„ν•  수 μžˆμŠ΅λ‹ˆλ‹€. λ‹€μŒμ€ μ˜ˆμ‹œμž…λ‹ˆλ‹€:

from ultralytics.models.yolo.detect import DetectionTrainer


class CustomTrainer(DetectionTrainer):
    def get_model(self, cfg, weights):
        """Loads a custom detection model given configuration and weight files."""
        ...


trainer = CustomTrainer(overrides={...})
trainer.train()
trained_model = trainer.best  # get best model

λ³€κ²½κ³Ό 같은 μΆ”κ°€ μ‚¬μš©μž μ§€μ •μ˜ 경우 loss function λ₯Ό μΆ”κ°€ν•˜κ±°λ‚˜ callbackλ₯Ό μ°Έμ‘°ν•  수 μžˆμŠ΅λ‹ˆλ‹€. 콜백 κ°€μ΄λ“œ.

What are the key components of the BaseTrainer in Ultralytics YOLO11?

그리고 BaseTrainer in Ultralytics YOLO11 serves as the foundation for training routines and can be customized for various tasks by overriding its generic methods. Key components include:

  • get_model(cfg, weights) λ₯Ό μ‚¬μš©ν•˜μ—¬ ν•™μŠ΅ν•  λͺ¨λΈμ„ κ΅¬μΆ•ν•©λ‹ˆλ‹€.
  • get_dataloader() λ₯Ό μ‚¬μš©ν•˜μ—¬ λ°μ΄ν„°λ‘œλ”λ₯Ό λΉŒλ“œν•©λ‹ˆλ‹€.

μ‚¬μš©μž 지정 및 μ†ŒμŠ€ μ½”λ“œμ— λŒ€ν•œ μžμ„Έν•œ λ‚΄μš©μ€ λ‹€μŒμ„ μ°Έμ‘°ν•˜μ„Έμš”. BaseTrainer μ°Έμ‘°.

How can I add a callback to the Ultralytics YOLO11 DetectionTrainer?

You can add callbacks to monitor and modify the training process in Ultralytics YOLO11 DetectionTrainer. For instance, here's how you can add a callback to log model weights after every training epoch:

from ultralytics.models.yolo.detect import DetectionTrainer


# callback to upload model weights
def log_model(trainer):
    """Logs the path of the last model weight used by the trainer."""
    last_weight_path = trainer.last
    print(last_weight_path)


trainer = DetectionTrainer(overrides={...})
trainer.add_callback("on_train_epoch_end", log_model)  # Adds to existing callbacks
trainer.train()

콜백 이벀트 및 μ§„μž… 지점에 λŒ€ν•œ μžμ„Έν•œ λ‚΄μš©μ€ 콜백 κ°€μ΄λ“œλ₯Ό μ°Έμ‘°ν•˜μ„Έμš”.

Why should I use Ultralytics YOLO11 for model training?

Ultralytics YOLO11 offers a high-level abstraction on powerful engine executors, making it ideal for rapid development and customization. Key benefits include:

  • μ‚¬μš© νŽΈμ˜μ„±: λͺ…령쀄과 Python μΈν„°νŽ˜μ΄μŠ€λŠ” λͺ¨λ‘ λ³΅μž‘ν•œ μž‘μ—…μ„ κ°„μ†Œν™”ν•©λ‹ˆλ‹€.
  • Performance: Optimized for real-time object detection and various vision AI applications.
  • Customization: Easily extendable for custom models, loss functions, and dataloaders.

Learn more about YOLO11's capabilities by visiting Ultralytics YOLO.

Can I use the Ultralytics YOLO11 DetectionTrainer for non-standard models?

Yes, Ultralytics YOLO11 DetectionTrainer λŠ” 맀우 μœ μ—°ν•˜λ©° λΉ„ν‘œμ€€ λͺ¨λΈμ— 맞게 μ‚¬μš©μž μ •μ˜ν•  수 μžˆμŠ΅λ‹ˆλ‹€. λ‹€μŒμ—μ„œ μƒμ†ν•˜μ—¬ DetectionTrainerλ₯Ό μ‚¬μš©ν•˜λ©΄ νŠΉμ • λͺ¨λΈμ˜ μš”κ΅¬ 사항을 μ§€μ›ν•˜κΈ° μœ„ν•΄ λ‹€μ–‘ν•œ 방법을 μ˜€λ²„λ‘œλ“œν•  수 μžˆμŠ΅λ‹ˆλ‹€. λ‹€μŒμ€ κ°„λ‹¨ν•œ μ˜ˆμž…λ‹ˆλ‹€:

from ultralytics.models.yolo.detect import DetectionTrainer


class CustomDetectionTrainer(DetectionTrainer):
    def get_model(self, cfg, weights):
        """Loads a custom detection model."""
        ...


trainer = CustomDetectionTrainer(overrides={...})
trainer.train()

보닀 μžμ„Έν•œ 지침과 μ˜ˆμ‹œλŠ” DetectionTrainer μ„€λͺ…μ„œλ₯Ό μ°Έμ‘°ν•˜μ„Έμš”.


πŸ“… Created 11 months ago ✏️ Updated 12 days ago

λŒ“κΈ€