bdd100k 라는 Driving 데이터 셋입니다.
KITTI와 다른 점은 지리적, 환경적 및 날씨 다양성을 가지고 있어 여러가지 환경에서의 데이터를 학습시킬 수 있습니다.
bdd100k는 Doc 사이트와 데이터를 다운받을 수 있는 사이트가 구분 되어있습니다.
Document : https://www.bdd100k.com/
Download : https://bdd-data.berkeley.edu/portal.html#download
Profile
Copyright ©2018. The Regents of the University of California (Regents). All Rights Reserved. THIS SOFTWARE AND/OR DATA WAS DEPOSITED IN THE BAIR OPEN RESEARCH COMMONS REPOSITORY ON 1/1/2021 Permission to use, copy, modify, and distribute this software a
bdd-data.berkeley.edu
원하는 데이터를 다운 받은 뒤 .JSON 파일을 참고하며 자신이 원하는 데이터를 골라 사용하면 됩니다.
json 파일 일부를 보시면
name : 이미지 이름
attribute: 여러 조건들이 담겨 있는 블록
weahter: 날씨정보
timeofday: 날짜,시간정보
scene: 장소 정보
timestamp: 타임스탬프 정보
labels: 검출한 객체, bounding box 정보를 담고있는 배열
id: 검출 객체에 대한 id 정보
attribute
occluded: 가려짐 여부
truncated: 잘림 여부
trafficLightColor: 신호등 색깔 정보
category: 검출 객체 클래스 정보
box2d: 바운딩 박스 정보
x1: 왼쪽 x좌표
y1: 상단 y좌표
x2: 오른쪽 x좌표
y2: 하단 y좌표
이미지 파일 불러오기
def get_image_file(image_filename: str):
image_file_path = os.path.join(image_filepath_root, image_filename)
image = cv2.imread(image_file_path, cv2.IMREAD_ANYCOLOR)
return image
.json 파일 읽기
with open(val_json_filepath, "r", encoding="UTF-8") as json_file:
val_labels = json.load(json_file)
각각의 데이터 정보 뽑기
box2d = label['box2d']
left_box2d = box2d["x1"]
right_box2d = box2d["x2"]
top_box2d = box2d["y1"]
bottom_box2d = box2d["y2"]
center_x = (left_box2d + right_box2d) / 2
center_y = (top_box2d + bottom_box2d) / 2
box_width = right_box2d - left_box2d
box_height = bottom_box2d - top_box2d
YOLO Format 맞추기(normalization)
yolo_x = center_x / img_width
yolo_y = center_y / img_height
yolo_box_width = box_width / img_width
yolo_box_height = box_height / img_height
BoundingBox 그리기 & Bounding Box 센터에 점 찍기
cv2.rectangle(image, (int(left_box2d), int(top_box2d)), (int(right_box2d), int(bottom_box2d)),(255,255,0), 4 )
cv2.circle(image,(int(center_x), int(center_y)), 3, (0, 0, 255))
class id x y width height 정보만 추출하여 txt 파일로 만들기
with open([다운 받은 yolo_labels/val 경로] + text_filename, "w+") as file:
file.write(f"{class_id} {yolo_x} {yolo_y} {yolo_box_width} {yolo_box_height}\n")
file.close()
10000개 레이블을 txt 파일로 변환했다면 똑같이 10000개의 txt파일이 존재할 것 입니다.
이 파일들을 하나의 txt 파일 안에 넣으려고 한다면
터미널에서
을 입력하면 tt.txt 파일 안에 10000개의 레이블 txt 파일 이름이 정리되있을 것입니다.