Skip to content

Commit

Permalink
Add unit testing about yolov8
Browse files Browse the repository at this point in the history
  • Loading branch information
SWHL committed Apr 23, 2024
1 parent 7105f34 commit 9ba0533
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

## Introduction

A tool for object detection and image segmentation dataset format conversion.
A tool for object detection and image segmentation dataset format conversion.

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

Expand All @@ -34,6 +34,9 @@ E(labelme) --> B
B --> F(labelImg)
F --> G(PubLayNet)
F --> J(YOLOv5)
J --> H(YOLOv8)
H --> J
```

## Installation
Expand Down
34 changes: 34 additions & 0 deletions tests/test_yolov5_to_yolov8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- encoding: utf-8 -*-
# @Author: SWHL
# @Contact: [email protected]
import shutil
import sys
from pathlib import Path

cur_dir = Path(__file__).resolve().parent
root_dir = cur_dir.parent

sys.path.append(str(root_dir))

from label_convert.yolov5_to_yolov8 import YOLOV5ToYOLOV8

test_file_dir = cur_dir / "test_files"

data_dir_name = "yolov5_dataset"


def test_normal():
data_dir = test_file_dir / data_dir_name
converter = YOLOV5ToYOLOV8(data_dir)
converter()

save_dir: Path = test_file_dir / f"{data_dir_name}_yolov8"
assert save_dir.exists()

train_img_dir = save_dir / "images" / "train"
assert train_img_dir.exists()

val_label_dir = save_dir / "labels" / "val"
assert val_label_dir.exists()

shutil.rmtree(save_dir)
40 changes: 40 additions & 0 deletions tests/test_yolov8_to_yolov5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- encoding: utf-8 -*-
# @Author: SWHL
# @Contact: [email protected]
import shutil
import sys
from pathlib import Path

cur_dir = Path(__file__).resolve().parent
root_dir = cur_dir.parent

sys.path.append(str(root_dir))

from label_convert.yolov8_to_yolov5 import YOLOV8ToYOLOV5

test_file_dir = cur_dir / "test_files"

data_dir_name = "yolov8_dataset"


def test_normal():
data_dir = test_file_dir / data_dir_name
converter = YOLOV8ToYOLOV5(data_dir)
converter()

save_dir: Path = test_file_dir / f"{data_dir_name}_yolov5"
assert save_dir.exists()

train_img_dir = save_dir / "images"
assert train_img_dir.exists()

val_label_dir = save_dir / "labels"
assert val_label_dir.exists()

train_txt_path = save_dir / "train.txt"
assert train_txt_path.exists()

classes_txt_path = save_dir / "classes.txt"
assert classes_txt_path.exists()

shutil.rmtree(save_dir)

0 comments on commit 9ba0533

Please sign in to comment.