From 2163aa9366ac2b5d41d826ef236a2c0b6c774997 Mon Sep 17 00:00:00 2001 From: Liwei Dai Date: Tue, 6 Jul 2021 16:32:21 +0800 Subject: [PATCH 1/2] Fix: remove calling function self inside function definition --- utils/general.py | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/general.py b/utils/general.py index f326acc7..a6e7b222 100644 --- a/utils/general.py +++ b/utils/general.py @@ -48,7 +48,6 @@ def torch_distributed_zero_first(local_rank: int): def init_seeds(seed=0): random.seed(seed) np.random.seed(seed) - init_seeds(seed=seed) def get_latest_run(search_dir='./runs'): From f9788d046b03a43dd8d62601a98047c8eeaa84d9 Mon Sep 17 00:00:00 2001 From: Liwei Dai Date: Wed, 28 Jul 2021 15:15:49 +0800 Subject: [PATCH 2/2] Feat: Support coco128 training and inference --- data/coco128.yaml | 29 +++++++++++++++++++++++++++++ run_inference.sh | 3 +++ run_training.sh | 3 +++ train.py | 5 +++-- 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 data/coco128.yaml create mode 100644 run_inference.sh create mode 100644 run_training.sh diff --git a/data/coco128.yaml b/data/coco128.yaml new file mode 100644 index 00000000..7d3eacc2 --- /dev/null +++ b/data/coco128.yaml @@ -0,0 +1,29 @@ +# COCO 2017 dataset http://cocodataset.org - first 128 training images +# Train command: python train.py --data coco128.yaml +# Default dataset location is next to YOLOv5: +# /parent +# /datasets/coco128 +# /yolov5 + + +# 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: ../datasets/coco128/images/train2017 # train images 128 images +val: ../datasets/coco128/images/train2017 # val images 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 + + +# Download script/URL (optional) +download: https://github.com/ultralytics/yolov5/releases/download/v1.0/coco128.zip \ No newline at end of file diff --git a/run_inference.sh b/run_inference.sh new file mode 100644 index 00000000..d955cb1c --- /dev/null +++ b/run_inference.sh @@ -0,0 +1,3 @@ +# !/bin/bash +python test.py --device 0 --batch-size 16 --img 640 --data data/coco128.yaml --cfg cfg/yolov4-pacsp.cfg --weights 'weights/yolov4_pacsp.pt' + diff --git a/run_training.sh b/run_training.sh new file mode 100644 index 00000000..4b53e6ba --- /dev/null +++ b/run_training.sh @@ -0,0 +1,3 @@ +# !/bin/bash +python train.py --device 0 --batch-size 16 --img 640 640 --data data/coco128.yaml --cfg cfg/yolov4-pacsp.cfg --weights 'weights/yolov4_pacsp.pt' --name yolov4-pacsp --epochs 100 + diff --git a/train.py b/train.py index 78b04b98..ba85387d 100644 --- a/train.py +++ b/train.py @@ -51,6 +51,7 @@ def train(hyp, opt, device, tb_writer=None): init_seeds(2 + rank) with open(opt.data) as f: data_dict = yaml.load(f, Loader=yaml.FullLoader) # model dict + # data_dict = yaml.safe_load(f) # model dict train_path = data_dict['train'] test_path = data_dict['val'] nc, names = (1, ['item']) if opt.single_cls else (int(data_dict['nc']), data_dict['names']) # number classes, names @@ -400,8 +401,8 @@ def train(hyp, opt, device, tb_writer=None): if last and not opt.weights: print(f'Resuming training from {last}') opt.weights = last if opt.resume and not opt.weights else opt.weights - if opt.local_rank == -1 or ("RANK" in os.environ and os.environ["RANK"] == "0"): - check_git_status() + # if opt.local_rank == -1 or ("RANK" in os.environ and os.environ["RANK"] == "0"): + # check_git_status() opt.hyp = opt.hyp or ('data/hyp.scratch.yaml') opt.data, opt.cfg, opt.hyp = check_file(opt.data), check_file(opt.cfg), check_file(opt.hyp) # check files