-
-
Notifications
You must be signed in to change notification settings - Fork 15.9k
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
KeyError occur when start training #958
Comments
Hello @Zzh-tju, thank you for your interest in our work! Please visit our Custom Training Tutorial to get started, and see our Jupyter Notebook 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:
For more information please visit https://www.ultralytics.com. |
When I changed
|
Same issue @Zzh-tju, but the issue is new, had no problems until yesterday. |
@Zzh-tju @karen-gishyan
sudo rm -rf yolov5 # remove existing
git clone https://github.com/ultralytics/yolov5 && cd yolov5 # clone latest
python detect.py # verify detection
# CODE TO REPRODUCE YOUR ISSUE HERE
If none of these apply to you, we suggest you close this issue and raise a new one using the Bug Report template, providing screenshots and minimum viable code to reproduce your issue. Thank you! RequirementsPython 3.8 or later with all requirements.txt dependencies installed, including $ pip install -r requirements.txt EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are passing. These tests evaluate proper operation of basic YOLOv5 functionality, including training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu. |
Hello @glenn-jocher , and thanks for your reply. I could see that the issue was with the way the labels were being read. I looked at your commit history in utils/datasets.py, and went back to your previous version, which solved the problem. |
@karen-gishyan I got the same problem as you, but it came out with "WARNING: /home/TrafficLight/JPEGImages/10141_0_1.jpg: image size <10 pixels" before, and which previous version were you use? thanks for your reply. |
@karen-gishyan same problem, how do u solve? fixes in datasets.py dont solved the problem
|
@sophiatmu I know this a temporary solution until the authors take a look at it, but in the utils/datasets.py, changed the code in lines 366,3
|
@Zzh-tju @karen-gishyan @lolpa1n @sophiatmu I've pushed a fix which should restore similar functionality to before. Lines 365 to 368 in 806e75f
Note that label paths are defined as the image paths with a .replace() statement that will replace the last instance of |
The dataset structure example provided by @Zzh-tju should work with no issues:
CI tests on fix 806e75f are all green. |
OK, fixed. |
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. |
Hi. I am facing the same issue when training on my custom dataset in ubuntu 18.04. However, this issue does not come up with coco128 dataset. |
@21143 it appears you may have environment problems. Please ensure you meet all dependency requirements if you are attempting to run YOLOv5 locally. If in doubt, create a new virtual Python 3.8 environment, clone the latest repo (code changes daily), and RequirementsPython 3.8 or later with all requirements.txt dependencies installed, including $ pip install -r requirements.txt EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are passing. These tests evaluate proper operation of basic YOLOv5 functionality, including training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu. |
Update: Fixed my issue by deleting the train.cache and val.cache files in the labels folder and re-running the training. I'm able to run training code now. Thanks ! |
train in my windows is ok , but when i upload to server gpu to train is occur error, i fix it by delete the label.cache in data folder |
I just found another thing that can cause this error: blank lines in the label file. So when I made labels for yolov5 training, I printed the labels in a wrong way, which made unintended blank lines between each object in a label file. Then I removed the blank lines of the label files, and the training works normally again. It makes sense because this error happened while caching labels not images. |
👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs. Access additional YOLOv5 🚀 resources:
Access additional Ultralytics ⚡ resources:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed! Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐! |
Fix for ultralytics#958 (comment) (cherry picked from commit 4d4a2b0)
@Farhad2590 hi there! It seems like you are running into an issue with the YOLOv5 training process. To help you out, could you please provide some more details about the specific problem you are facing? Specifically, any error messages or stack traces that you are encountering would be helpful in diagnosing the issue. Additionally, please share the command or code that you are using for training, as well as any relevant information about your dataset and environment. With this information, we can better understand the problem and provide you with an appropriate solution. Looking forward to assisting you further! |
I am trying to yolov7 model |
@Farhad2590 make sure you have a For example, the
Ensure that you have correctly defined the path to your training dataset in the If this issue persists, please provide the content of your |
detect: weights=['last.pt'], source=test, data=data\coco128.yaml, imgsz=[416, 416], conf_thres=0.25, iou_thres=0.45, max_det=1000, device=, view_img=False, save_txt=True, save_csv=False, save_conf=True, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=runs\detect, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False, vid_stride=1 Fusing layers... |
@sanjayjackson this error typically occurs when there is an issue with your class labels in the provided To resolve this issue, please ensure the following:
By verifying the above points, you should be able to resolve the |
thanks i tried but didn't work
################################### |
@sanjayjackson it seems like you are still encountering issues with your YOLOv5 training, even after modifying the Here are a few things you can try to resolve the issue:
Please check these suggestions and let me know if the issue persists or if you have any further questions. |
❔Question
@glenn-jocher
Currently, I work on a face detection. I use the following command to train.
python train.py --img 640 --batch 16 --epochs 5 --data ./data/face.yaml --cfg ./models/yolov5s.yaml --weights yolov5s.pt
All the training datasets are
And their coresponding labels are
But I have an error:
And
face/labels/train/10000.txt
is0 0.6062500000000001 0.6017543859649123 0.3775 0.5719298245614035
I don't know how can I solve this problem.
The text was updated successfully, but these errors were encountered: