Skip to content

Commit 9ba0533

Browse files
committed
Add unit testing about yolov8
1 parent 7105f34 commit 9ba0533

File tree

3 files changed

+78
-1
lines changed

3 files changed

+78
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
## Introduction
2020

21-
A tool for object detection and image segmentation dataset format conversion.
21+
A tool for object detection and image segmentation dataset format conversion.
2222

2323
Supports conversion between labelme tool annotated data, labelImg tool annotated data, YOLO, PubLayNet and COCO data set formats.
2424

@@ -34,6 +34,9 @@ E(labelme) --> B
3434
B --> F(labelImg)
3535
F --> G(PubLayNet)
3636
F --> J(YOLOv5)
37+
38+
J --> H(YOLOv8)
39+
H --> J
3740
```
3841

3942
## Installation

tests/test_yolov5_to_yolov8.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# -*- encoding: utf-8 -*-
2+
# @Author: SWHL
3+
# @Contact: [email protected]
4+
import shutil
5+
import sys
6+
from pathlib import Path
7+
8+
cur_dir = Path(__file__).resolve().parent
9+
root_dir = cur_dir.parent
10+
11+
sys.path.append(str(root_dir))
12+
13+
from label_convert.yolov5_to_yolov8 import YOLOV5ToYOLOV8
14+
15+
test_file_dir = cur_dir / "test_files"
16+
17+
data_dir_name = "yolov5_dataset"
18+
19+
20+
def test_normal():
21+
data_dir = test_file_dir / data_dir_name
22+
converter = YOLOV5ToYOLOV8(data_dir)
23+
converter()
24+
25+
save_dir: Path = test_file_dir / f"{data_dir_name}_yolov8"
26+
assert save_dir.exists()
27+
28+
train_img_dir = save_dir / "images" / "train"
29+
assert train_img_dir.exists()
30+
31+
val_label_dir = save_dir / "labels" / "val"
32+
assert val_label_dir.exists()
33+
34+
shutil.rmtree(save_dir)

tests/test_yolov8_to_yolov5.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# -*- encoding: utf-8 -*-
2+
# @Author: SWHL
3+
# @Contact: [email protected]
4+
import shutil
5+
import sys
6+
from pathlib import Path
7+
8+
cur_dir = Path(__file__).resolve().parent
9+
root_dir = cur_dir.parent
10+
11+
sys.path.append(str(root_dir))
12+
13+
from label_convert.yolov8_to_yolov5 import YOLOV8ToYOLOV5
14+
15+
test_file_dir = cur_dir / "test_files"
16+
17+
data_dir_name = "yolov8_dataset"
18+
19+
20+
def test_normal():
21+
data_dir = test_file_dir / data_dir_name
22+
converter = YOLOV8ToYOLOV5(data_dir)
23+
converter()
24+
25+
save_dir: Path = test_file_dir / f"{data_dir_name}_yolov5"
26+
assert save_dir.exists()
27+
28+
train_img_dir = save_dir / "images"
29+
assert train_img_dir.exists()
30+
31+
val_label_dir = save_dir / "labels"
32+
assert val_label_dir.exists()
33+
34+
train_txt_path = save_dir / "train.txt"
35+
assert train_txt_path.exists()
36+
37+
classes_txt_path = save_dir / "classes.txt"
38+
assert classes_txt_path.exists()
39+
40+
shutil.rmtree(save_dir)

0 commit comments

Comments
 (0)