From 5e9b1b6ca356926130fd131b42a7007360811b5c Mon Sep 17 00:00:00 2001 From: "yongle.wu" Date: Wed, 17 May 2023 10:52:56 +0000 Subject: [PATCH 1/4] Signed-off-by: yongle.wu add yolov8 for pytorch model link #I6VR33 add yolov8 for pytorch model --- cv/detection/yolov8/README.md | 53 +++++++++++++++++++++++++++++++++++ cv/detection/yolov8/test.py | 9 ++++++ 2 files changed, 62 insertions(+) create mode 100755 cv/detection/yolov8/README.md create mode 100644 cv/detection/yolov8/test.py diff --git a/cv/detection/yolov8/README.md b/cv/detection/yolov8/README.md new file mode 100755 index 000000000..f0d104d32 --- /dev/null +++ b/cv/detection/yolov8/README.md @@ -0,0 +1,53 @@ +## yolov8 + +[Ultralytics](https://ultralytics.com) [YOLOv8](https://github.com/ultralytics/ultralytics) is a cutting-edge, state-of-the-art (SOTA) model that builds upon the success of previous YOLO versions and introduces new features and improvements to further boost performance and flexibility. YOLOv8 is designed to be fast, accurate, and easy to use, making it an excellent choice for a wide range of object detection and tracking, instance segmentation, image classification and pose estimation tasks. + +## Environment + +``` +pip3 install ultralytics +``` + +## coco + +``` +$ mkdir -p /datasets/coco +$ cd /datasets/ +wget https://github.com/ultralytics/yolov5/releases/download/v1.0/coco2017labels-segments.zip +cd coco +mkdir images +wget http://images.cocodataset.org/zips/train2017.zip +wget http://images.cocodataset.org/zips/val2017.zip +wget http://images.cocodataset.org/zips/test2017.zip +``` + +``` +. +├── coco +│   ├── annotations +│   │   └── instances_val2017.json +│   │   └── instances_train2017.json +│   ├── images +│   │   ├── train2017 +│   │   └── val2017 +│   │   └── test2017 +│   ├── labels +│   │   ├── train2017 +│   │   └── val2017 +│   ├── LICENSE +│   ├── README.txt +│   ├── test-dev2017.txt +│   ├── train2017.txt +│   └── val2017.txt +└── coco2017labels-segments.zip +``` + +## Training + +```bash +python3 test.py +``` + +| model | GPU | FP32 | +|-------------------| ----------- | ------------------------------------ | +| yolov8n | 8 cards | MAP=37.3 | diff --git a/cv/detection/yolov8/test.py b/cv/detection/yolov8/test.py new file mode 100644 index 000000000..c43adc21f --- /dev/null +++ b/cv/detection/yolov8/test.py @@ -0,0 +1,9 @@ +from ultralytics import YOLO + +# Load a model +model = YOLO("yolov8n.yaml") # build a new model from scratch +# model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) + +# Use the model +model.train(data="coco.yaml",epochs=100, imgsz=640,batch=512,device="0,1,2,3,4,5,6,7") # train the model +metrics = model.val() # evaluate model performance on the validation set \ No newline at end of file -- Gitee From 6934d10c242e5715182b51c04ab824c002d0adb7 Mon Sep 17 00:00:00 2001 From: "yongle.wu" Date: Thu, 1 Jun 2023 08:26:07 +0000 Subject: [PATCH 2/4] modified README.md --- cv/detection/yolov8/README.md | 50 +++++++++++++++++------------------ cv/detection/yolov8/test.py | 18 +++++++++++-- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/cv/detection/yolov8/README.md b/cv/detection/yolov8/README.md index f0d104d32..3ffa5cf95 100755 --- a/cv/detection/yolov8/README.md +++ b/cv/detection/yolov8/README.md @@ -8,40 +8,38 @@ pip3 install ultralytics ``` -## coco +### Download coco2017 ``` $ mkdir -p /datasets/coco $ cd /datasets/ -wget https://github.com/ultralytics/yolov5/releases/download/v1.0/coco2017labels-segments.zip -cd coco -mkdir images -wget http://images.cocodataset.org/zips/train2017.zip -wget http://images.cocodataset.org/zips/val2017.zip -wget http://images.cocodataset.org/zips/test2017.zip -``` ``` -. -├── coco -│   ├── annotations -│   │   └── instances_val2017.json -│   │   └── instances_train2017.json -│   ├── images -│   │   ├── train2017 -│   │   └── val2017 -│   │   └── test2017 -│   ├── labels -│   │   ├── train2017 -│   │   └── val2017 -│   ├── LICENSE -│   ├── README.txt -│   ├── test-dev2017.txt -│   ├── train2017.txt -│   └── val2017.txt -└── coco2017labels-segments.zip + +Go to visit [COCO official website](https://cocodataset.org/#download), then select the COCO dataset you want to download. + +Take coco2017 dataset as an example, specify `/path/to/coco2017` to your COCO path in later training process, the unzipped dataset path structure sholud look like: + +```bash +coco2017 +├── annotations +│   ├── instances_train2017.json +│   ├── instances_val2017.json +│ └── ... +├── train2017 +│ ├── 000000000009.jpg +│ ├── 000000000025.jpg +│ └── ... +├── val2017 +│ ├── 000000000139.jpg +│ ├── 000000000285.jpg +│ └── ... +├── train2017.txt +├── val2017.txt +└── ... ``` + ## Training ```bash diff --git a/cv/detection/yolov8/test.py b/cv/detection/yolov8/test.py index c43adc21f..dcad550b5 100644 --- a/cv/detection/yolov8/test.py +++ b/cv/detection/yolov8/test.py @@ -1,3 +1,18 @@ +# Copyright (c) 2023, Shanghai Iluvatar CoreX Semiconductor Co., Ltd. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + from ultralytics import YOLO # Load a model @@ -5,5 +20,4 @@ model = YOLO("yolov8n.yaml") # build a new model from scratch # model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training) # Use the model -model.train(data="coco.yaml",epochs=100, imgsz=640,batch=512,device="0,1,2,3,4,5,6,7") # train the model -metrics = model.val() # evaluate model performance on the validation set \ No newline at end of file +model.train(data="coco.yaml",epochs=300, imgsz=640,batch=128,device="0,1,2,3,4,5,6,7") # train the model -- Gitee From 2da5b7d85620cdc03f729c65201fe2623838e861 Mon Sep 17 00:00:00 2001 From: "yongle.wu" Date: Thu, 1 Jun 2023 08:43:46 +0000 Subject: [PATCH 3/4] modified yolov8 --- cv/detection/yolov8/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cv/detection/yolov8/README.md b/cv/detection/yolov8/README.md index 3ffa5cf95..711b6c946 100755 --- a/cv/detection/yolov8/README.md +++ b/cv/detection/yolov8/README.md @@ -3,6 +3,16 @@ [Ultralytics](https://ultralytics.com) [YOLOv8](https://github.com/ultralytics/ultralytics) is a cutting-edge, state-of-the-art (SOTA) model that builds upon the success of previous YOLO versions and introduces new features and improvements to further boost performance and flexibility. YOLOv8 is designed to be fast, accurate, and easy to use, making it an excellent choice for a wide range of object detection and tracking, instance segmentation, image classification and pose estimation tasks. ## Environment +```bash +## Install zlib 1.2.9 +wget http://www.zlib.net/fossils/zlib-1.2.9.tar.gz +tar xvf zlib-1.2.9.tar.gz +cd zlib-1.2.9/ +./configure && make install + +## install libGL +yum install mesa-libGL +``` ``` pip3 install ultralytics -- Gitee From 1885ac492e577fbf0296853a7067f2b1bc93cbc1 Mon Sep 17 00:00:00 2001 From: "yongle.wu" Date: Thu, 1 Jun 2023 09:35:05 +0000 Subject: [PATCH 4/4] modifed yolov8 map --- cv/detection/yolov8/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv/detection/yolov8/README.md b/cv/detection/yolov8/README.md index 711b6c946..708509aba 100755 --- a/cv/detection/yolov8/README.md +++ b/cv/detection/yolov8/README.md @@ -58,4 +58,4 @@ python3 test.py | model | GPU | FP32 | |-------------------| ----------- | ------------------------------------ | -| yolov8n | 8 cards | MAP=37.3 | +| yolov8n | 8 cards | MAP=36.3 | -- Gitee