Using CLIP as a Zero-Shot Classifier CLIP zero-shot 분류 사용법
How to build a classifier with zero training:
- Drop each class name into a template like
"a photo of a {class}"and embed the text. - Compute cosine similarity against the image embedding.
- Pick the closest class. Done.
- Averaging several templates (prompt ensembling) reliably buys you accuracy.
- Domain words help too: for satellite imagery,
"a satellite photo of …". - Weak spots: fine-grained distinctions (dog breeds, car models), counting, spatial relations.
When your data has no labels, run this first as the baseline.
학습 없이 분류기를 만드는 절차:
- 각 클래스 이름을
"a photo of a {class}"같은 템플릿에 넣어 텍스트 임베딩 생성. - 이미지 임베딩과 코사인 유사도 계산.
- 가장 유사한 클래스 선택. 끝.
- 템플릿 여러 개를 평균(prompt ensembling)하면 확실히 오른다.
- 도메인 단어를 넣는 것도 유효 — 위성사진이면
"a satellite photo of …". - 약점: 세밀한 구분(품종·모델명), 개수 세기, 위치 관계.
내 데이터에 라벨이 없을 때 베이스라인으로 가장 먼저 돌려볼 것.