Closed lamsongianm closed 2 years ago
👋 Hello @lamsongianm, 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 support@ultralytics.com.
Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:
git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install
YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
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.
@lamsongianm i.e. python train.py --data coco128.yaml
@glenn-jocher Hello, I am training my model, therefore, I create a new yaml file for training
@lamsongianm 👋 Hello! Thanks for asking about YOLOv5 🚀 dataset formatting. To train correctly your data must be in YOLOv5 format. Please see our Train Custom Data tutorial for full documentation on dataset setup and all steps required to start training your first model. A few excerpts from the tutorial:
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
After using a tool like Roboflow Annotate to label your images, export your labels to YOLO format, with one *.txt
file per image (if no objects in image, no *.txt
file is required). The *.txt
file specifications are:
class x_center y_center width height
format.x_center
and width
by image width, and y_center
and height
by image height.The label file corresponding to the above image contains 2 persons (class 0
) and a tie (class 27
):
Organize your train and val images and labels according to the example below. YOLOv5 assumes /coco128
is inside a /datasets
directory next to the /yolov5
directory. YOLOv5 locates labels automatically for each image by replacing the last instance of /images/
in each image path with /labels/
. For example:
../datasets/coco128/images/im0.jpg # image
../datasets/coco128/labels/im0.txt # label
Good luck 🍀 and let us know if you have any other questions!
@glenn-jocher Hello, I try fixing the problem, but the system shows the same error.
(behavior_detection) ron@VirtualBox:~/PycharmProjects/behavior_detection/yolov5$ python train.py --img 320 --batch 16 --epochs 3 --data dataset.yaml --weights yolov5s.pt usage: train.py [-h] [--weights WEIGHTS] [--cfg CFG] [--training_data TRAINING_DATA] [--hyp HYP] [--epochs EPOCHS] [--batch-size BATCH_SIZE] [--imgsz IMGSZ] [--rect] [--resume [RESUME]] [--nosave] [--noval] [--noautoanchor] [--evolve [EVOLVE]] [--bucket BUCKET] [--cache [CACHE]] [--image-weights] [--device DEVICE] [--multi-scale] [--single-cls] [--optimizer {SGD,Adam,AdamW}] [--sync-bn] [--workers WORKERS] [--project PROJECT] [--name NAME] [--exist-ok] [--quad] [--cos-lr] [--label-smoothing LABEL_SMOOTHING] [--patience PATIENCE] [--freeze FREEZE [FREEZE ...]] [--save-period SAVE_PERIOD] [--local_rank LOCAL_RANK] [--entity ENTITY] [--upload_dataset [UPLOAD_DATASET]] [--bbox_interval BBOX_INTERVAL] [--artifact_alias ARTIFACT_ALIAS] train.py: error: unrecognized arguments: --data dataset.yaml
Hi @lamsongianm could you solve it? I'm having the same issue
@geduardo I just reinstall the yolov5.....
@geduardo I just reinstall the yolov5.....
And did it help?
I have a similar issue - error: unrecognized arguments: –-name
I dont see what is wrong python segment/train.py --img 640 --batch 16 --epochs 300 --data data/coco128-seg.yaml --weights '' --cfg yolov5s.yaml –-name 02-yolo5-s-hyp-high --hyp hyp.scratch-high.yaml
@geduardo I just reinstall the yolov5.....
And did it help?
I have a similar issue -
error: unrecognized arguments: –-name
I dont see what is wrong
python segment/train.py --img 640 --batch 16 --epochs 300 --data data/coco128-seg.yaml --weights '' --cfg yolov5s.yaml –-name 02-yolo5-s-hyp-high --hyp hyp.scratch-high.yaml
@Robotatron it looks like you are using a long dash for --name... That's why it's not recognizing the argument
Don't leave gaps anywhere between the dash and the arguments. Probably this should solve it. !python train.py --device 0 --batch-size 16 --epochs 100 --img 640 640 --data data/custom_data.yml --hyp data/hyp.scratch.custom.yml --cfg cfg/training/yolov7x-custom.yml --weights yolov7x.pt --name yolov7x-custom.yml
@varadtechx That's correct 👍. Ensure there are no extra spaces between the dashes and the argument names. This should resolve the issue with the unrecognized arguments. For example, instead of --name
or –-name
, use --name
. Let me know if you need further assistance!
what should be the follow for inference in YOLONAS: I tried the following command but it doesn't works and give me the error.
python inference.py -n 2 --data Rdataset/data.yaml --model yolo_nas_l --weight /average_model.pth --source /test.png --conf 0.5 --save
Error: usage: inference.py [-h] -n NUM [-m {yolo_nas_s,yolo_nas_m,yolo_nas_l}] -w WEIGHT -s SOURCE [-c CONF] [--save] [--hide] inference.py: error: unrecognized arguments: --data Rdataset/data.yaml
This is my directory looks like while the dataset and data.yaml files are at Rdataset directory.
How to resolve this error Please.
@KamranUmer it appears there's a misunderstanding regarding the usage of the inference.py
script for YOLONAS. Based on the error message you've shared, the script does not accept a --data
argument, which is why you're encountering the "unrecognized arguments" error.
For YOLONAS inference, you typically need to specify the number of networks (-n
), the model type (-m
), the weights file (-w
), the source file or directory (-s
), the confidence threshold (-c
), and whether to save the output (--save
). The --data
argument is not used in this context as it's more relevant for training scenarios where dataset configuration is necessary.
Given your command:
python inference.py -n 2 --data Rdataset/data.yaml --model yolo_nas_l --weight /average_model.pth --source /test.png --conf 0.5 --save
You should remove the --data Rdataset/data.yaml
part since it's not recognized by inference.py
. Your revised command should look something like this:
python inference.py -n 2 -m yolo_nas_l -w /average_model.pth -s /test.png -c 0.5 --save
Make sure the paths to your weights file (-w
) and source image (-s
) are correct. If /average_model.pth
and /test.png
are meant to be relative paths from the current directory, you might need to remove the leading slash to avoid pointing to the root directory of your filesystem.
If you have further questions or encounter more issues, feel free to ask!
Search before asking
Question
Hi everyone, when I train the model, the system shows the error, please help to fix it, thanks.
(behavior_detection) ronaldlam@ronaldlam-VirtualBox:~/PycharmProjects/behavior_detection/yolov5$ python train.py --img 320 --batch 16 --epochs 3 --data dataset.yaml --weights yolov5s.pt usage: train.py [-h] [--weights WEIGHTS] [--cfg CFG] [--training_data TRAINING_DATA] [--hyp HYP] [--epochs EPOCHS] [--batch-size BATCH_SIZE] [--imgsz IMGSZ] [--rect] [--resume [RESUME]] [--nosave] [--noval] [--noautoanchor] [--evolve [EVOLVE]] [--bucket BUCKET] [--cache [CACHE]] [--image-weights] [--device DEVICE] [--multi-scale] [--single-cls] [--optimizer {SGD,Adam,AdamW}] [--sync-bn] [--workers WORKERS] [--project PROJECT] [--name NAME] [--exist-ok] [--quad] [--cos-lr] [--label-smoothing LABEL_SMOOTHING] [--patience PATIENCE] [--freeze FREEZE [FREEZE ...]] [--save-period SAVE_PERIOD] [--local_rank LOCAL_RANK] [--entity ENTITY] [--upload_dataset [UPLOAD_DATASET]] [--bbox_interval BBOX_INTERVAL] [--artifact_alias ARTIFACT_ALIAS] train.py: error: unrecognized arguments: --data dataset.yaml
Additional
No response