ultralytics / yolov3

YOLOv3 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
10.18k stars 3.44k forks source link

How can I change the last GIOU loss function to a specified loss function, such as CIOU? #1338

Closed zhongqiu1245 closed 4 years ago

zhongqiu1245 commented 4 years ago

thank you for your amazing job!
How can I change the last GIOU loss function to a specified loss function, such as CIOU?

github-actions[bot] commented 4 years ago

Hello @zhongqiu1245, thank you for your interest in our work! Ultralytics has open-sourced YOLOv5 at https://github.com/ultralytics/yolov5, featuring faster, lighter and more accurate object detection. YOLOv5 is recommended for all new projects.

To continue with this repo, please visit our Custom Training Tutorial to get started, and see our Google Colab Notebook, Docker Image, and GCP Quickstart Guide for example environments.

If this is a bug report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom model or data training question, please note that Ultralytics does not provide free personal support. As a leader in vision ML and AI, we do offer professional consulting, from simple expert advice up to delivery of fully customized, end-to-end production solutions for our clients, such as:

For more information please visit https://www.ultralytics.com.

glenn-jocher commented 4 years ago

@zhongqiu1245 in train.py compute_loss() you simply switch GIoU=True to CIoU=True.

zhongqiu1245 commented 4 years ago

@glenn-jocher Thank you! I found the compute_loss in train.py, as follows:

        # Loss
        loss, loss_items = compute_loss(pred, targets, model)
        if not torch.isfinite(loss):
            print('WARNING: non-finite loss, ending training ', loss_items)
            return result

Could you tell me how can I switch GIoU=True to CIoU=True? thank you!

glenn-jocher commented 4 years ago

https://github.com/ultralytics/yolov3/blob/a587d39cd447b85219e761734b5f1d5cb30197d8/utils/utils.py#L387

zhongqiu1245 commented 4 years ago

@glenn-jocher Thank you very much!!!

glenn-jocher commented 11 months ago

@zhongqiu1245 you're welcome! Feel free to reach out if you have any more questions.