1. git clone https://github.com/WongKinYiu/yolov7.git
-
cd yolov7/
-
!pip install requirements.txt
-
script for dividing data into train,test & validation
python yolov_train_test_split.py
create customdata folder inside yolov7 data set download link :customdata
-inside images paste all train & valid images
-inside labels all labels of train & valid image
. go insiode data folder & create custom_data.yaml & add path of image & labels (i.e .txt)
# train and val data as 1) directory: path/images/, 2) file: path/images.txt, or 3) list: [path1/images/, path2/images/]
train: ./customdata/train.txt
val: ./customdata/valid.txt
# number of classes
nc: 3
# class names
names: ['pistol','rifle','revolver']
for creating train.txt & val.txt use (it contains the path of images )
!python genrate_test.py
- go inside cfg/training & select any .yaml file do changes such as no classes
- start training using
!python train.py --workers 8 --device 0 --batch-size 16 --data data/custom_data.yaml --img 640 640 --cfg cfg/training/yolov7_custom_3.yaml --weights '' --name yolov7xcustom3 --hyp data/hyp.scratch.p5.yaml --epochs 200
- inference on video/image
python yolov7_inference.py
# add alll file path inside this file
python detect.py --weights yolov7.pt --conf 0.25 --img-size 640 --source inference/images/horses.jpg