添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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

Search before asking

  • I have searched the YOLOv5 issues and discussions and found no similar questions.
  • Question

    i am trying to train yolov5 on a custom dataset containing 3 classes.once the training is done,during validation i get this error :

    Validating runs/train/Result4/weights/best.pt... Fusing layers... Model Summary: 476 layers, 87212152 parameters, 0 gradients, 217.1 GFLOPs Class Images Labels P R [email protected] [email protected]:.95: 100% 1/1 [00:04<00:00, 4.19s/it] Traceback (most recent call last): File "train.py", line 625, in <module> main(opt) File "train.py", line 522, in main train(opt.hyp, opt, device, callbacks) File "train.py", line 429, in train compute_loss=compute_loss) # val best model with plots File "/usr/local/lib/python3.7/dist-packages/torch/autograd/grad_mode.py", line 28, in decorate_context return func(*args, **kwargs) File "/content/val.py", line 240, in run p, r, ap, f1, ap_class = ap_per_class(*stats, plot=plots, save_dir=save_dir, names=names) File "/content/utils/metrics.py", line 78, in ap_per_class plot_mc_curve(px, f1, Path(save_dir) / 'F1_curve.png', names, ylabel='F1') File "/content/utils/metrics.py", line 323, in plot_mc_curve ax.plot(px, y, linewidth=1, label=f'{names[i]}') # plot(confidence, metric) KeyError: 1

    even though i wrote custom yaml file like this :

    %%writetemplate /content/DataFile/data.yaml
    train: /content/convertor/fold0/images/train 
    val: /content/convertor/fold0/images/val 
    test: /content/convertor/fold0/images/val 
    nc: 3 
    names: ["name","age","mobile"] 
    

    i still get the error above and while inferring, all the bounding boxes are given "name" as label ,instead of predicting these 3 classes names: ["name","age","mobile"]
    my model always predicts "name" for all 3 fields(please check the last image attached in the colab code):
    here is the code with outputs and errors : https://colab.research.google.com/drive/1Pyz5hCi0fpmQ4lFV9rvAcdMp2yg9KN1P#scrollTo=ogZdrD4OY2Wg

    how can i solve this issue? thanks in advance

    Additional

    👋 Hello @mobassir94, 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://ultralytics.com or email Glenn Jocher at [email protected].

    Requirements

    Python>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

    $ git clone https://github.com/ultralytics/yolov5
    $ cd yolov5
    $ 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):

  • Google Colab and Kaggle notebooks with free GPU: Open In Colab Open In Kaggle
  • Google Cloud Deep Learning VM. See GCP Quickstart Guide
  • Amazon Deep Learning AMI. See AWS Quickstart Guide
  • Docker Image. See Docker Quickstart Guide Docker Pulls
  • Status

    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), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

    @mobassir94 👋 hi, thanks for letting us know about this possible problem with YOLOv5 🚀. We've created a few short guidelines below to help users provide what we need in order to get started investigating a possible problem.

    How to create a Minimal, Reproducible Example

    When asking a question, people will be better able to provide help if you provide code that they can easily understand and use to reproduce the problem. This is referred to by community members as creating a minimum reproducible example. Your code that reproduces the problem should be:

  • Minimal – Use as little code as possible to produce the problem
  • Complete – Provide all parts someone else needs to reproduce the problem
  • Reproducible – Test the code you're about to provide to make sure it reproduces the problem
  • For Ultralytics to provide assistance your code should also be:

  • Current – Verify that your code is up-to-date with GitHub master, and if necessary git pull or git clone a new copy to ensure your problem has not already been solved in master.
  • Unmodified – Your problem must be reproducible using official YOLOv5 code without changes. Ultralytics does not provide support for custom code ⚠️.
  • If you believe your problem meets all the above criteria, please close this issue and raise a new one using the 🐛 Bug Report template with a minimum reproducible example to help us better understand and diagnose your problem.

    Thank you! 😃

    Hi @raftaarrashedin,

    Thank you for following up! I'm glad to hear that you managed to resolve the issue. For the benefit of others who might encounter a similar problem, could you please share the solution you found?

    If anyone else is experiencing similar issues, here are a few steps you can take to troubleshoot:

    Verify Dataset Configuration: Ensure your data.yaml file is correctly formatted and paths are accurate. For example:

    train: /path/to/train/images
    val: /path/to/val/images
    nc: 3
    names: ['name', 'age', 'mobile']

    Check Label Files: Make sure your label files are in the correct YOLO format, with one .txt file per image and each line in the format class x_center y_center width height.

    Update to Latest Versions: Ensure you are using the latest versions of YOLOv5 and PyTorch. You can update YOLOv5 with:

    git pull
    pip install -r requirements.txt

    Reproduce the Issue: If the problem persists, please provide a minimal, reproducible example so we can investigate further. You can find more details on creating a reproducible example here.

    Sharing your solution will greatly help the community. Thank you for your cooperation and happy coding! 🚀