Image classification pipeline

매일 공부(ML)·2021년 10월 18일
0

CS231n

목록 보기
2/4

Image classification

  • 정의: 사진을 보고 사물을 판단하는 것(CV계열)

  • 특징: Image classification 가능-> Detection, Segmentation, Image captioning가능

  • Problem

    • semantic gap
  • challenges

    • viewpoint variation
    • lllumination
    • Deformation
    • Occlusion
    • Background clutter
    • Intraclass variation
  • An image classifier

    def predict(image):

    #code

    return class_label

  • Data-driven approach

    i) 이미지와 레이블이 있는 데이터 셋 만들기

    ii) 이미지 분류기가 학습하기 위해 ML 사용한다

    iii) 테스트 이미지를 넣어서 분류기가 잘 판단하는지 판단한다.

    iv) 코드로 구현

    def train(train_images, train_labels):
    #build a model for image -> labels...
    return model

    def predict(model, test_images):
    #predict test_labels using the model...
    return test_labels

    Nearest Neighbor Classifier

    : 학습용으로 주로 쓰이지 현재는 쓰이지 않는 방식

    : Remember all training images and their labels( def train)

    : Predict the label of the most similar training image( def predict)

  • Example dataset: CIFAR - 10 (Slides 2-19 참고)

: code로 구현

  • training data의 사이즈에 따라서 속도는 선형적으로 늘어난다.

  • L2 기법을 이용하면 훈련 데이터안에서 NN 분류기의 정확성은 100%이다

Distance metric(Hyperparameter)

L1 distance

  • 공식 :

  • 예시 :

    L2 distance

  • 공식 :

K-Nearest Neighbor

  • K : Hyperparameter이다

  • K개의 가장 가까운 이미지들을 찾은 후 이 이미지들이 다수결로 보딩을 하는 것.

  • NN보다 성능이 좋음

  • 대략적 모습 사진으로 보기

  • 훈련 데이터안에서 K- NN 분류기의 정확성은 Case by case 이다.

  • 테스트 시간이 너무 길다

Try to find best hyperparameters for test set

  • traind data가 적절한 경우

  • train data가 적은 경우

  • distance metrics가 매우 직관적이지 않음

  • 단편적 예시

Linear Classification

-정의 : 이미지 안에서 모든 픽셀 값들의 가중치의 합.

  • f(x, W) = Wx

    • x: image

    • W: parameters

  • Example

--> 색상에 의존하는 경향성이 있기 때문에 그리 좋진 않음

  • Linear Classifier이 분류하기 어려운 데이터 셋

    i) Negative Film (정 반대의 색으로 처리) : 형태 인식은 하지만 컬러가 반대이기에 힘듦.

    ii) Gray color: 색이 기준이 아니라 다른 세부사항 기준으로 보아야하기 때문에 어렵다

    iii) 형태는 다르지만 색상이 동일: 분간하기 힘들다.

  • interpreting a linear classifier(공간적 해석)

    : Score function - f(xi,W,b) = Wxi + b

profile
성장을 도울 아카이빙 블로그

0개의 댓글