재활용품 분리배출을 실천하기 가장 힘든 이유는 분리배출 방법이 다양하고 많기 때문에 정확하게 알아보기 귀찮다는 것이 가장 큰 이유다.
사용자들이 다양하고 복잡한 쓰레기 분리배출 방법을 보다 편리하게 이해하고 실천할 수 있도록 도와주는 모바일 어플리케이션을 개발하는 것을 목표로 한다.
데이터 전처리 및 모델 학습
# 이미지의 resize 비율만큼 bbox값 계산
def resize_bbox(image, resized_image, json_file):
with open(json_file, 'r', encoding='utf-8') as j_f:
data = json.load(j_f)
x1 = int(data['Bounding'][0]['x1'])
y1 = int(data['Bounding'][0]['y1'])
x2 = int(data['Bounding'][0]['x2'])
y2 = int(data['Bounding'][0]['y2'])
y_ratio = resized_image.shape[0] / image.shape[0]
x_ratio = resized_image.shape[1] / image.shape[1]
bbox_resized = list(map(round, [x1*x_ratio, x2*x_ratio, y1*y_ratio, y2*y_ratio]))
return bbox_resized
# bbox value를 YOLO format으로 변환
def cvt2YOLO(img_size, bbox):
dw = 1./img_size[0]
dh = 1./img_size[1]
x = (bbox[0] + bbox[1])/2.0
y = (bbox[2] + bbox[3])/2.0
w = bbox[1] - bbox[0]
h = bbox[3] - bbox[2]
x = x*dw
w = w*dw
y = y*dh
h = h*dh
return (x,y,w,h)
데이터 분배
# 데이터 분배 (8:1:1)
def distribute_files(path, exts):
from sklearn.model_selection import train_test_split
images = [x for x in os.listdir(path) if x.split('.')[-1] in exts['image_ext']]
labels = [x.split('_')[0] for x in images]
train_input, test_input, train_target, test_target = train_test_split(images, labels, test_size=0.1, random_state=42, shuffle=True, stratify=labels)
train_input, val_input, train_target, val_target = train_test_split(train_input, train_target, test_size=0.1, random_state=42, shuffle=True, stratify=train_target)
all_files = {'train': train_input, 'val': val_input, 'test': test_input}
for dir, file_list in tqdm(all_files.items(), desc='데이터 분배'):
move_by_dirs(path, dir, file_list)
train1 | train2 | train3 | train4 | |
---|---|---|---|---|
epochs | 10 | 10 | 10 | 10 |
patience | 5 | 5 | 5 | 5 |
batch_size | 16 | 16 | 32 | 32 |
optimizer | AdamW | AdamW | AdamW | AdamW |
learning_rate | 0.01 | 0.001 | 0.01 | 0.001 |
box loss | 0.31641 | 0.31976 | 0.32979 | 0.31192 |
cls loss | 0.25473 | 0.2663 | 0.3003 | 0.25236 |
학습시간 | 93h | 95h | 93h | 95h |
안녕하세요! 올려주신 글 너무 잘 읽었습니다. 한 가지 여쭤보고 싶은 것이 있습니다. AI hub에서 데이터셋을 다운받으려고 하는데 용량이 너무 커서 로컬 환경에 다운이 받아지지 않습니다. 혹시 어떻게 하셨는지 여쭙고 싶습니다.