관리 메뉴

jisoleil's coding good thing

AI 시각지능 딥러닝 3일차 본문

AIVLE/7주차

AI 시각지능 딥러닝 3일차

jisoleil 2023. 3. 16. 00:59
  • Pretrained Model                                                                                                                                                            내가 풀고자 하는 문제와 비슷하면서 사이즈가 큰 데이터로 이미 학습이 되어 있는 모델

https://keras.io/api/applications/

 

Keras documentation: Keras Applications

Keras Applications Keras Applications are deep learning models that are made available alongside pre-trained weights. These models can be used for prediction, feature extraction, and fine-tuning. Weights are downloaded automatically when instantiating a mo

keras.io

 

  • Transfer Learning                                                                                                                                                                                                             높은 정확도를 비교적 짧은 시간 내에 달성할 수 있기 때문에 컴퓨터 비전 분야에서 유명한 방법론 중 하나, 컴퓨터 비전에서 말하는 전이학습은 주로 사전학습 된 모델 (pre-trained model) 을 이용하는 것을 뜻함  -> 이미 '잘 만들어진' 모델들을 가져다가 사용

Pretrained model을 어떻게 활용해서 사용 할 수 있는지 보여주는 사진이다.

  1. 데이터 셋의 크기가 작은 반면 데이터 유사성은 높은 경우                                                                                               ->모델을 재학습할 필요 없음, 출력 레이어를 해당 문제에 맞게 수정
  2. 데이터 그기가 작고 데이터 유사도가 낮은 경우                                                                                                                ->Input~ hidden layer 까지 frozen하고, output 직전 또는 output layer만 데이터 세트에 맞게 커스텀
  3. 데이터 세트의 크기는 크지만 데이터 유사성은 매우 낮은 경우                                                                                        -> 데이터 세트가 크기 때문에 신경망 훈련 하는 것 자체가 효과적
  4. 데이터 크기가 크고 데이터 유사도가 높은 경우                                                                                                                ->이상적인 상황, 훈련만 해라

 

  • Object Detection                                                                                                                                                                                                            Object 감지와 Object 의 클래스까지 알아내는 것-> 컴퓨터비전, 영상처리와 관계가 깊은 컴퓨터 기술

실습

UltraLytics YOLO v3 Image Detection 따라하기

!cd yolov3; python detect.py \
    --weights '/content/yolov3/pretrained/yolov3-tiny.pt' \
    --source '/content/yolov3/data/images/14th_street.jpg' \
    --project '/content/yolov3/detected' \
    --name 'images' \
    --img 640 \
    --conf-thres 0.5 \
    --iou-thres 0.4 \
    --line-thickness 2 \
    --exist-ok \
    --device cpu
 
detect.py 사용 예시
--weights: pretrained 가중치

--source: dectet 대상의 경로

--project/ name: dectet 후 파일 생성 경로

--conf-thres/ iou-thres: Threshold 값

 

 

*callback의 ModelCheckPoint 클래스

 

:모델을 저장할 때 사용되는 콜백함수

mcp = ModelCheckpoint(filepath='/content/model_save.h5',#모델 저장경로(h5로 저장하는 걸 선호)
                      monitor='val_loss',#모델 저장의 관심 대상
                      verbose=1,#어느 시점에서 저장되는지 알려줌
                      save_best_only=True,#최고 성능 모델만 저장
                      save_weights_only=False)#가중치만 저장할 것인지, 모델 구조도 저장할 것인지

 

참고: 

https://velog.io/@boom109/Transfer-learning-and-Pre-trained-Models-%ED%99%9C%EC%9A%A9

 

Transfer learning and Pre-trained Models 활용

일반적으로 딥러닝 모델을 제대로 훈련시키려면 많은 수의 데이터가 필요하다. 하지만 현실에서는 충분히 큰 데이터셋을 얻는 것은 쉽지 않은 일이다. 데이터

velog.io

 

'AIVLE > 7주차' 카테고리의 다른 글

AI 시각지능 딥러닝 4일차  (3) 2023.03.17
AI 시각지능 딥러닝 2일차  (1) 2023.03.14
AI 시각지능 딥러닝 1일차  (1) 2023.03.14
Comments