-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
mosaic: 1.0 # 모자이크 증강 비율 | ||
mixup: 0.0 # 믹스업 증강 비율 | ||
erasing: 0.0 # 랜덤 지우기 비율 | ||
crop_fraction: 1.0 # 크롭 비율 (전체 이미지 사용) | ||
hsv_h: 0.015 # Hue 변화 비율 | ||
hsv_s: 0.7 # Saturation 변화 비율 | ||
hsv_v: 0.4 # Value 변화 비율 | ||
degrees: 5.0 # 회전 각도를 0.0에서 5.0으로 수정하여 데이터 다양화 | ||
translate: 0.1 # 이동 비율 설정 | ||
scale: 0.5 # 스케일 변화 비율 설정 | ||
shear: 0.0 # 전단 변형 각도 설정 | ||
perspective: 0.0 # 원근 변환 비율 설정 | ||
flipud: 0.0 # 수직 반전 비율 | ||
fliplr: 0.5 # 수평 반전 비율 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,38 @@ | ||
from ultralytics import YOLO | ||
import torch | ||
import yaml | ||
|
||
# 모델 설정 정보 | ||
yaml_path = "yolo11x-seg.yaml" # 새로운 모델 설정을 위한 YAML 파일 | ||
pretrained_weights = "yolo11x-seg.pt" # 사전 훈련된 가중치 파일 경로 | ||
transfer_weights = "yolo11x.pt" # YAML 빌드 시 사용할 가중치 파일 경로 | ||
yaml_path = "yolo11x-seg.yaml" # 새로운 모델 설정을 위한 YAML 파일 경로 | ||
pretrained_weights = "yolo11x-seg.pt" # 사전 학습된 가중치 파일 경로 | ||
transfer_weights = "yolo11x.pt" # YAML로 모델을 생성할 때 사용할 가중치 파일 경로 | ||
|
||
# 모델 빌드 또는 가중치 로드 | ||
model = YOLO(yaml_path) # YAML 파일로 새 모델 빌드 | ||
model = YOLO(pretrained_weights) # 사전 훈련된 모델 로드 | ||
model = YOLO(yaml_path).load(transfer_weights) # YAML로 빌드하고 가중치 로드 | ||
# 증강기 설정 파일 불러오기 | ||
augmenter_config_path = "./args.yaml" # 데이터 증강 설정을 위한 YAML 파일 경로 | ||
with open(augmenter_config_path, 'r') as file: | ||
augmenter_args = yaml.safe_load(file) # args.yaml 파일을 읽어서 설정 정보를 로드 | ||
|
||
# 모델 훈련 설정 | ||
data_path = "/data/ephemeral/home/jiwan/yolo/data.yaml" # 데이터 설정 파일 경로 | ||
epochs = 250 | ||
imgsz = 1280 | ||
batch_size = 4 # 추가한 batch_size 설정 | ||
# 모델 생성 또는 가중치 로드 | ||
model = YOLO(yaml_path).load(transfer_weights) | ||
|
||
# 모델 학습 설정 | ||
data_path = "/data/ephemeral/home/jiwan/level2-cv-semanticsegmentation-cv-15-lv3/yolo/data.yaml" # 데이터 구성 파일 경로 | ||
epochs = 100 # 학습 반복 횟수 | ||
imgsz = 2048 # 입력 이미지 크기 | ||
batch_size = 1 # 배치 크기 설정 | ||
|
||
# GPU 메모리 정리 | ||
torch.cuda.empty_cache() | ||
|
||
# 모델 훈련 시작 | ||
# 모델 학습 시작 | ||
# args.yaml에서 불러온 설정을 반영하고, 중복된 'data' 키를 제거한 상태로 학습을 진행 | ||
results = model.train( | ||
data=data_path, | ||
epochs=epochs, | ||
imgsz=imgsz, | ||
batch=batch_size | ||
data=data_path, # 데이터 경로 설정 | ||
epochs=epochs, # 학습 반복 횟수 설정 | ||
imgsz=imgsz, # 입력 이미지 크기 설정 | ||
batch=batch_size, # 배치 크기 설정 | ||
augment=True, # 데이터 증강을 사용하도록 설정 | ||
#**augmenter_args # args.yaml에서 로드한 증강 설정 추가 적용 (data는 제거된 상태) | ||
) | ||
|
||
print("훈련이 완료되었습니다.") | ||
print("Training completed.") # 학습 완료 메시지 출력 |