ultralytics / yolov5

YOLOv5 πŸš€ in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
49.01k stars 15.99k forks source link

about some dataset problem #5217

Closed camillychen closed 2 years ago

camillychen commented 2 years ago

❔Question

Use train.py & coco128.yml that have problem like list: Weights & Biases: run 'pip install wandb' to automatically track and visualize YOLOv5 runs (RECOMMENDED) hyperparameters: lr0=0.01, lrf=0.2, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.5, cls_pw=1.0, obj=1.0, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0 TensorBoard: Start with 'tensorboard --logdir runs\train', view at http://localhost:6006/ Traceback (most recent call last): File "C:\yolov5-6.0\train.py", line 620, in main(opt) File "C:\yolov5-6.0\train.py", line 517, in main train(opt.hyp, opt, device, callbacks) File "C:\yolov5-6.0\train.py", line 103, in train data_dict = data_dict or check_dataset(data) # check if None File "C:\yolov5-6.0\utils\general.py", line 345, in check_dataset data = yaml.safe_load(f) # dictionary File "C:\yolov5-6.0\venv\lib\site-packages\yaml__init__.py", line 162, in safe_load return load(stream, SafeLoader) File "C:\yolov5-6.0\venv\lib\site-packages\yaml__init__.py", line 114, in load return loader.get_single_data() File "C:\yolov5-6.0\venv\lib\site-packages\yaml\constructor.py", line 49, in get_single_data node = self.get_single_node() File "C:\yolov5-6.0\venv\lib\site-packages\yaml\composer.py", line 36, in get_single_node document = self.compose_document() File "C:\yolov5-6.0\venv\lib\site-packages\yaml\composer.py", line 55, in compose_document node = self.compose_node(None, None) File "C:\yolov5-6.0\venv\lib\site-packages\yaml\composer.py", line 84, in compose_node node = self.compose_mapping_node(anchor) File "C:\yolov5-6.0\venv\lib\site-packages\yaml\composer.py", line 127, in compose_mapping_node while not self.check_event(MappingEndEvent): File "C:\yolov5-6.0\venv\lib\site-packages\yaml\parser.py", line 98, in check_event self.current_event = self.state() File "C:\yolov5-6.0\venv\lib\site-packages\yaml\parser.py", line 438, in parse_block_mapping_key raise ParserError("while parsing a block mapping", self.marks[-1], yaml.parser.ParserError: while parsing a block mapping in "data\coco128.yaml", line 10, column 1 expected , but found '' in "data\coco128.yaml", line 17, column 9

Additional context

i have label some car that class name is 'F_C_R', 'F_C_W', 'F_C_K', 'B_C_S', 'B_C_K'==>this mean is B:back C:car W:white color how to solve this problem, thank you

github-actions[bot] commented 2 years ago

πŸ‘‹ Hello @camillychen, 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 glenn.jocher@ultralytics.com.

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):

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

glenn-jocher commented 2 years ago

@camillychen your dataset YAML is not parsing correctly. See Train Custom Data tutorial for data yaml guidelines:

1.1 Create dataset.yaml

COCO128 is an example small tutorial dataset composed of the first 128 images in COCO train2017. These same 128 images are used for both training and validation to verify our training pipeline is capable of overfitting. data/coco128.yaml, shown below, is the dataset config file that defines 1) the dataset root directory path and relative paths to train / val / test image directories (or *.txt files with image paths), 2) the number of classes nc and 3) a list of class names:

# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: ../datasets/coco128  # dataset root dir
train: images/train2017  # train images (relative to 'path') 128 images
val: images/train2017  # val images (relative to 'path') 128 images
test:  # test images (optional)

# Classes
nc: 80  # number of classes
names: [ 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light',
         'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow',
         'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
         'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard',
         'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
         'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
         'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone',
         'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear',
         'hair drier', 'toothbrush' ]  # class names

YOLOv5 Tutorials

camillychen commented 2 years ago

@glenn-jocher

I have chang coco128.yaml as below: (2021_06_07_17_17_33==>in this folder have many picture about car in the highway, ex: 'F_C_R', 'F_C_W', 'F_C_K', 'B_C_S', 'B_C_K'==>this mean is B:back C:car W:white color)

train: images/2021_06_07_17_17_33 # train images (relative to 'path') 128 images nc: 20 # number of classes names: [ 'dog','person','cat','tv','car','meatballs','marinara sauce','tomato soup','chicken noodle soup','french onion soup','chicken breast','ribs','pulled pork','hamburger','cavity','F_C_R', 'F_C_W', 'F_C_K', 'B_C_S', 'B_C_K' ]

then, in the train .py that have parser.add_argument('--weights', type=str, default=ROOT / 'yolov5l.pt', help='initial weights path') parser.add_argument('--cfg', type=str, default='', help='model.yaml path') parser.add_argument('--data', type=str, default=ROOT / 'data/coco128.yaml', help='dataset.yaml path') parser.add_argument('--hyp', type=str, default=ROOT / 'data/hyps/hyp.scratch.yaml', help='hyperparameters path') parser.add_argument('--epochs', type=int, default=10) parser.add_argument('--batch-size', type=int, default=16, help='total batch size for all GPUs') parser.add_argument('--imgsz', '--img', '--img-size', type=int, default=640, help='train, val image size (pixels)')

run this have some problem, i want to know how can solve this problem that can to do this training?

  1. it is need train: images/train2017 & val: images/train2017 ? is same picture? or not?
  2. how to set dataset is rights?

thank you

glenn-jocher commented 2 years ago

@camillychen yes this all seems fine, but you probably want more epochs, i.e. 100 to start and then use less if you overfit.

Your train and val set should be different images, coco128 uses the same just to verify you can overfit before you train a real dataset.

github-actions[bot] commented 2 years ago

πŸ‘‹ 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 ⭐!