[Dataset] Udacity2 to YOLO

최재혁·2022년 4월 8일
0

Dataset

목록 보기
3/3

Udacity2

fixed large
select darknet annotation

https://public.roboflow.com/object-detection/self-driving-car

Change class number

change udacity class number to custom dataset class number

#!/usr/bin/env python3
import os

dir_path = 'udacity/export'
class1 = int()
class2 = int()
class3 = int()
class11 = int()

for (root, directories, files) in os.walk(dir_path):
    for file in files:
        if '.txt' in file:
            file_path = os.path.join(root, file)
            with open(file_path, "r") as f:
                lines = f.readlines()                    
            with open(file_path, "w") as f: 
                for line in lines:
                    class_num = line.split()[0] 
                    print("before : ",line)
                    tmp = line.split()
                    if class_num == '0':
                        tmp[0] = '3'
                        class1 += 1 
                    if class_num == '1':
                        tmp[0] = '2'
                        class2 += 1
                    if class_num == '2':
                        tmp[0] = '0'
                        class3 += 1
                    if class_num == '10':
                        tmp[0] = '5'
                        class11 += 1
                    if class_num == '0' or class_num == '1' or class_num == '2' or class_num == '10':
                        f.write(line)
                print(file_path," : refine ends")   

print("motocycle : ", class1)
print("car : ", class2)
print("person : ", class3)
print("Truck : ", class11)
profile
Autonomous driving vision

0개의 댓글