mirror of
https://github.com/azaion/ai-training.git
synced 2026-04-22 09:06:35 +00:00
fix augmentation - correct bboxes to be within borders+margin
Add classes = 80 as default number in yaml file
This commit is contained in:
@@ -18,6 +18,8 @@ train_set = 70
|
||||
valid_set = 20
|
||||
test_set = 10
|
||||
|
||||
DEFAULT_CLASS_NUM = 80
|
||||
|
||||
|
||||
def form_dataset(from_date: datetime):
|
||||
makedirs(today_dataset, exist_ok=True)
|
||||
@@ -89,7 +91,10 @@ def create_yaml():
|
||||
lines = ['names:']
|
||||
for c in annotation_classes:
|
||||
lines.append(f'- {annotation_classes[c].name}')
|
||||
lines.append(f'nc: {len(annotation_classes)}')
|
||||
classes_count = len(annotation_classes)
|
||||
for c in range(DEFAULT_CLASS_NUM - classes_count):
|
||||
lines.append(f'- Class-{c + classes_count + 1}')
|
||||
lines.append(f'nc: {DEFAULT_CLASS_NUM}')
|
||||
|
||||
lines.append(f'test: test/images')
|
||||
lines.append(f'train: train/images')
|
||||
@@ -132,17 +137,19 @@ def get_latest_model():
|
||||
|
||||
if __name__ == '__main__':
|
||||
latest_date, latest_model = get_latest_model()
|
||||
# create_yaml()
|
||||
# form_dataset(latest_date)
|
||||
|
||||
|
||||
model_name = latest_model if latest_model is not None and path.isfile(latest_model) else 'yolov8m.yaml'
|
||||
print(f'Initial model: {model_name}')
|
||||
model = YOLO(model_name)
|
||||
|
||||
# cur_folder = path.join(datasets_dir, f'{prefix}2024-06-18')
|
||||
cur_folder = path.join(datasets_dir, f'{prefix}2024-09-19')
|
||||
|
||||
cur_folder = today_dataset
|
||||
# cur_folder = today_dataset
|
||||
yaml = abspath(path.join(cur_folder, 'data.yaml'))
|
||||
results = model.train(data=yaml, epochs=100, batch=60, imgsz=640)
|
||||
results = model.train(data=yaml, epochs=100, batch=58, imgsz=640)
|
||||
|
||||
shutil.copytree(results.save_dir, path.join(models_dir, today_folder))
|
||||
shutil.rmtree('runs')
|
||||
|
||||
Reference in New Issue
Block a user