ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.34k stars 16.25k forks source link

Custom Model with 1 Class 54 MB file size #2279

Closed lgeuder closed 3 years ago

lgeuder commented 3 years ago

❔Question

Why is my 'best.pt' file 54 MB large after training on Yolov5s? Compared with the coco 5s model which is about 14MB large I am starting to feel like I did something wrong.

Additional context

thats what i ran: python train.py --cfg './models/yolov5s.yaml' --batch-size 64 --data 'data.yaml'

github-actions[bot] commented 3 years ago

👋 Hello @lgeuder, thank you for your interest in 🚀 YOLOv5! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

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 training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

glenn-jocher commented 3 years ago

@lgeuder after training completes you will have an FP16 model.

During training checkpoints contain FP16 models and FP32 optimizer gradients.

lgeuder commented 3 years ago

@glenn-jocher I might have misunderstood the workflow of training data. If i run the detection succesfully, do i have to run further trainings again?

glenn-jocher commented 3 years ago

@lgeuder I'm not sure what you mean. You don't have to do anything. Standard workflow is to 1) train a model, and 2) use it. During training checkpoints are loaded with various extra attributes that are required for resuming trainings. When a training completes these are stripped and the checkpoint sizes are then the same as the official models.

lgeuder commented 3 years ago

@glenn-jocher my training process is finished but the the best.pt file i got in /runs/../weights is 54 mb. Should i run it again? Do you recommend any customizations due to the fact that i only need 2 classes. My usecase is pretty much like the blood cells one. I am not aiming to get high precision detections all I need is FPS. The target is running stable with more than 1 fps on a raspberry pie 😅

glenn-jocher commented 3 years ago

@lgeuder if your file is larger than 14 MB it is likely training was interrupted or you are training with an older codebase. You can manually strip optimizers from a checkpoint if you want using the same method as train.py: https://github.com/ultralytics/yolov5/blob/0070995bd58629d4628d11b1c8de9788aa55379b/train.py#L397-L401

lgeuder commented 3 years ago

okay thanks already, i‘ll try