Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YOLO 객체 탐지 — 커스텀 과일 검출 & 추론 / YOLO Object Detection

English summary. Hands-on object detection with the YOLO family: a custom fruit detector trained with YOLOv5 on a 60+ class Roboflow fruit dataset (5,000 train / 1,000 val images), plus YOLOv8 inference via the Ultralytics API. This repo documents the training workflow, configuration, and detection results — the upstream framework source is intentionally not vendored here (linked instead), keeping the repo to the author's own configuration, inference code, and outputs.

Python YOLOv5 YOLOv8 Task


개요

원스테이지 객체 탐지 모델 YOLO를 두 세대에 걸쳐 실습한 저장소입니다.

  1. YOLOv5 — 커스텀 과일 데이터셋으로 전이학습(transfer learning)하여 나만의 검출기(fruit_best.pt)를 학습.
  2. YOLOv8 — Ultralytics 최신 API로 사전학습 모델을 불러와 추론 파이프라인(박스/마스크/키포인트/확률) 구성.

저작권/용량 정책: YOLOv5 프레임워크 원본 소스와 학습 가중치(*.pt), 결과 영상(*.mp4)은 이 저장소에 포함하지 않습니다. 프레임워크는 아래 상류 저장소를 참조하세요. 본 저장소에는 본인 작성 추론 코드 + 대표 탐지 결과 이미지만 포함합니다.

데이터셋 — 커스텀 과일 검출

항목 내용
출처 Roboflow 공개 과일 데이터셋 (YOLO 포맷, .rf. 라벨링)
규모 학습 5,000장 / 검증 1,000장
클래스 63종 과일·채소 (다중 클래스)
라벨 YOLO txt 포맷 (class cx cy w h, 정규화 좌표)

학습 설정은 data/fruit_data.yaml에 정의했습니다 (클래스 수 nc: 63, 클래스명 목록 포함).

63개 클래스 전체 목록

Apple, Apricot, Avocado, Banana, Beetroot, Blueberry, Cactus, Cantaloupe, Carambula, Cauliflower, Cherry, Chestnut, Clementine, Cocos, Dates, Eggplant, Ginger, Granadilla, Grape, Grapefruit, Guava, Hazelnut, Huckleberry, Kaki, Kiwi, Kohlrabi, Kumquats, Lemon, Limes, Lychee, Mandarine, Mango, Mangostan, Maracuja, Melon, Mulberry, Nectarine, Nut, Onion, Orange, Papaya, Passion, Peach, Pear, Pepino, Pepper, Physalis, Pineapple, Pitahaya, Plum, Pomegranate, Pomelo, Potato, Quince, Rambutan, Raspberry, Redcurrant, Salak, Strawberry, Tamarillo, Tangelo, Tomato, Walnut

데이터셋 분석 & 증강 시각화 (실제 학습 산출물)

YOLOv5 학습 과정에서 자동 생성된 실제 산출물입니다. (results/)

데이터셋 라벨 분석 학습 배치 (모자이크 증강)
dataset labels train batch mosaic

왼쪽은 63개 클래스별 인스턴스 수(균형 잡힌 분포)와 바운딩 박스의 위치·크기 분포를 보여주고, 오른쪽은 모자이크 데이터 증강이 적용된 실제 학습 배치(라벨 박스 포함)입니다.

방법론

YOLOv5 커스텀 학습 (전이학습)

# 상류 yolov5 clone 후, data yaml에 FruitDataset 경로/클래스 정의
python train.py --img 640 --batch 16 --epochs 100 \
                --data fruit.yaml --weights yolov5s.pt --name fruit
# 결과: runs/train/fruit/weights/best.pt  (→ fruit_best.pt)
python detect.py --weights fruit_best.pt --source <image_or_video>

사전학습 가중치(yolov5s.pt)에서 출발해 과일 클래스에 맞게 헤드를 재학습하는 전이학습 전략을 사용했습니다.

YOLOv8 추론 (src/yolov8_추론.py)

from ultralytics import YOLO
model = YOLO("yolov8n.pt")          # COCO 사전학습 모델
results = model("./bus.jpg")        # 추론
for r in results:
    r.boxes; r.masks; r.keypoints; r.probs   # 결과 객체
    r.save(filename="result.jpg")

결과 — 대표 탐지 이미지

커스텀 과일 검출 (YOLOv5) 차량 검출
fruit detection car detection

학습한 과일 검출기가 이미지 내 여러 과일을 바운딩 박스로 탐지하는 것을 확인했습니다.

실행 방법

pip install -r requirements.txt
python src/yolov8_추론.py            # YOLOv8 추론 (가중치 자동 다운로드)

YOLOv5 커스텀 학습 재현은 상류 저장소를 clone 후 위 학습 커맨드를 참고하세요.

배운 점

  • 사전학습 모델 → 커스텀 클래스 전이학습으로 소규모 데이터에서도 검출기를 만드는 워크플로우 체득.
  • YOLO 라벨 포맷(정규화 좌표)과 data.yaml 구성 방식 이해.
  • YOLOv5(스크립트 기반) vs YOLOv8(Python API) 세대별 사용성 차이 비교.

참고


NVIDIA AI Academy Seoul · Cohort 1 포트폴리오의 일부 — 전체 보기

About

YOLOv5 커스텀 과일 검출(63클래스) + YOLOv8 추론 | Ultralytics

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages