Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's the difference between last.pt&best.pt, and which one should i use when i test my custom data? #582

Closed
PromiseXu1 opened this issue Jul 31, 2020 · 11 comments
Labels
question Further information is requested Stale

Comments

@PromiseXu1
Copy link

PromiseXu1 commented Jul 31, 2020

I have tried your work of yolov3 on my custom data, and when i train on yolov5 i find that yolov5 is more excellent! I just train for 100 epochs, the map50 have reached at 80! And i will train more epochs to see if it could be better .

But the question is that when i finish the train, and start to test, which weight.pt should i choose? And what's the difference between last.pt and best.pt?

Could you help me? Thanks sincerely.

@PromiseXu1 PromiseXu1 added the question Further information is requested label Jul 31, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Jul 31, 2020

Hello @PromiseXu1, thank you for your interest in our work! Please visit our Custom Training Tutorial to get started, and see our Jupyter Notebook Open In Colab, Docker Image, and Google Cloud 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 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:

  • Cloud-based AI systems operating on hundreds of HD video streams in realtime.
  • Edge AI integrated into custom iOS and Android apps for realtime 30 FPS video inference.
  • Custom data training, hyperparameter evolution, and model exportation to any destination.

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

@glenn-jocher
Copy link
Member

@PromiseXu1 last.pt are the weights from the last epoch of training. best.pt are the best weights recorded during training.

@PromiseXu1
Copy link
Author

PromiseXu1 commented Jul 31, 2020

@glenn-jocher ah it seems so obviously, thanks for your patient... but i find sometimes best.pt not always be there, and i find someone have mentioned it, are you dealing with it?

@PromiseXu1
Copy link
Author

1

@TaoXieSZ
Copy link

@PromiseXu1 Because in exp11, when you resume from another exp, the model you trained didn't have better mAP than the one you resume from.

@glenn-jocher
Copy link
Member

@PromiseXu1 --resuming still has a few bugs to iron out, so I would avoid it as much as possible.

Best.pt will be saved anytime a new best fitness is observed on your validation set. We define fitness as a weighted combination of metrics:

yolov5/utils/utils.py

Lines 881 to 885 in 48e15be

def fitness(x):
# Returns fitness (for use with results.txt or evolve.txt)
w = [0.0, 0.0, 0.1, 0.9] # weights for [P, R, mAP@0.5, mAP@0.5:0.95]
return (x[:, :4] * w).sum(1)

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@Yu-Hang
Copy link

Yu-Hang commented Jun 24, 2021

yolov5/utils/utils.py

Lines 881 to 885 in 48e15be

def fitness(x):
# Returns fitness (for use with results.txt or evolve.txt)
w = [0.0, 0.0, 0.1, 0.9] # weights for [P, R, mAP@0.5, mAP@0.5:0.95]
return (x[:, :4] * w).sum(1)

Does this mean the weights for new best fitness will be recorded even if the model already overfits?

@glenn-jocher
Copy link
Member

@Yu-Hang they are exactly as they sound, the last and best checkpoints during your training.

If the model overfits then by definition there will be no new best fitness.

@Yu-Hang
Copy link

Yu-Hang commented Jun 24, 2021

Let me ask more specifically. The fitness function does not include any loss metrics. So, if you train for a large epoch, [P, R, mAP@0.5, mAP@0.5:0.95] are increasing, but some val loss starts to increases as well (which indicates overfitting?). In this case, will this creates new best fitness?

@glenn-jocher
Copy link
Member

glenn-jocher commented Jun 24, 2021

@Yu-Hang fitness function is defined here. best.pt is saved on every new best-fitness epoch.

yolov5/utils/metrics.py

Lines 13 to 17 in 417a2f4

def fitness(x):
# Model fitness as a weighted combination of metrics
w = [0.0, 0.0, 0.1, 0.9] # weights for [P, R, mAP@0.5, mAP@0.5:0.95]
return (x[:, :4] * w).sum(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

4 participants