[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,114 +2,285 @@
|
||||
id: wiki-2026-0508-computer-vision
|
||||
title: Computer Vision
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: []
|
||||
aliases: [CV, computer vision, image classification, object detection, segmentation, ViT, CLIP, SAM, depth estimation]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.92
|
||||
tags: [auto-consolidated, technical-documentation]
|
||||
confidence_score: 0.95
|
||||
verification_status: applied
|
||||
tags: [computer-vision, deep-learning, cnn, vit, segmentation, detection, sam, clip, dino, image-classification]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-08
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: Python
|
||||
framework: PyTorch / Transformers / Detectron2 / Ultralytics / SAM
|
||||
---
|
||||
|
||||
# [[Computer Vision|Computer Vision]]
|
||||
# Computer Vision
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "디지털 눈의 진화: 픽셀의 단순한 나열인 이미지와 비디오 데이터를 컴퓨터가 인간처럼 이해하고, 객체를 식별하며, 공간의 깊이를 읽고, 의미 있는 정보를 추출하게 만드는 인공지능의 시각 중추."
|
||||
## 매 한 줄
|
||||
> **"매 pixel 의 meaning"**. 매 classification → 매 detection → 매 segmentation → 매 depth → 매 generation. 매 modern: 매 ViT 의 dominant + 매 foundation model (CLIP, SAM, DINOv2). 매 multi-modal LLM 의 vision encoder 의 base.
|
||||
|
||||
---
|
||||
## 매 핵심 task
|
||||
|
||||
> "픽셀의 나열에서 사물과 맥락을 읽어내는 AI의 눈을 완성하라" — 이미지나 비디오로부터 유의미한 정보를 추출, 분석 및 이해하기 위한 기술 체계로, 자율주행부터 의료 영상 판독까지 시각 지능의 정수.
|
||||
### Classification
|
||||
- 매 image → 매 class.
|
||||
- 매 ImageNet, 매 ResNet, 매 ViT.
|
||||
|
||||
---
|
||||
### Detection
|
||||
- 매 image → 매 bbox + class.
|
||||
- 매 [[Bounding-Box-Regression]] 참조.
|
||||
- 매 YOLO, DETR.
|
||||
|
||||
> 디지털 이미지와 비디오에서 고차원적인 의미를 추출하여 기계가 세상을 '보고' '이해하게' 만드는 AI의 감각 기관.
|
||||
### Segmentation
|
||||
- **Semantic**: 매 pixel → 매 class.
|
||||
- **Instance**: 매 pixel → 매 instance.
|
||||
- **Panoptic**: 매 결합.
|
||||
- 매 SAM (Segment Anything).
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
컴퓨터 비전(Computer Vision)은 가시광선 등 물리적 신호를 디지털 데이터로 변환하고 분석하여 '본다'는 행위를 기계로 구현하는 기술입니다.
|
||||
### Depth estimation
|
||||
- **Monocular**: 매 single image → 매 depth.
|
||||
- **Stereo**: 매 두 camera.
|
||||
- 매 MiDaS, Depth Anything.
|
||||
|
||||
1. **핵심 태스크**:
|
||||
* **Classification**: 무엇이 들어있는가? (예: 개/고양이 구분)
|
||||
* **Detection**: 무엇이 '어디에' 있는가? (Bounding Box 표시)
|
||||
* **Segmentation**: 픽셀 단위로 객체의 경계선 따기.
|
||||
* **Depth Estimation**: 공간의 입체적 거리감 파악.
|
||||
2. **기반 기술**:
|
||||
* CNN(Convolutional Neural Networks)에서 최근에는 Vision [[Transformers|Transformers]](ViT)로 아키텍처가 진화 중.
|
||||
### Pose estimation
|
||||
- **2D / 3D**.
|
||||
- 매 OpenPose, MediaPipe, ViTPose.
|
||||
|
||||
---
|
||||
### Tracking
|
||||
- 매 video 의 across frames.
|
||||
- 매 ByteTrack, BoT-SORT.
|
||||
|
||||
- **추출된 패턴:** 고차원의 시각 데이터를 특징 추출 레이어를 통해 저차원의 추상적 개념으로 변환하고, 이를 다시 객체 인식이나 분할 등의 태스크로 구체화하는 인지 패턴.
|
||||
- **핵심 기술 계보:**
|
||||
- **Traditional CV:** 소벨 필터, Canny edge detection, SIFT 등 수학적 필터 기반 특징 추출.
|
||||
- **CNN (Convolutional Neural Networks):** 이미지의 지역적 특징을 계층적으로 학습 (AlexNet, ResNet).
|
||||
- **Object Detection:** 이미지 내 물체의 위치와 종류 파악 (YOLO, Faster R-CNN).
|
||||
- **Segmentation:** 픽셀 단위로 영역 구분 (U-Net, Mask R-CNN).
|
||||
- **Vision Transformer (ViT):** 텍스트 처리의 트랜스포머 구조를 이미지에 적용하여 전역적 맥락 파악.
|
||||
- **의의:** 인간의 시각 기능을 기계로 완벽히 구현하여 물리 세계와 디지털 세계의 경계를 허묾.
|
||||
### Generation
|
||||
- 매 GAN, Diffusion, Stable Diffusion.
|
||||
- 매 [[AI 이미지 생성 및 편집 워크플로우 (AI Image Generation & Editing Workflow)]] 참조.
|
||||
|
||||
---
|
||||
### OCR
|
||||
- 매 text from image.
|
||||
- 매 PaddleOCR, Tesseract, GPT-4V.
|
||||
|
||||
- **추출된 패턴:** 이미지 픽셀에서 특징(Feature)을 추출하고 이를 계층적으로 구조화하여 객체를 인식하는 비전 처리 패턴.
|
||||
- **세부 내용:**
|
||||
- CNN(합성곱 신경망)에서 ViT(비전 트랜스포머)로의 아키텍처 진화.
|
||||
- 이미지 분류, 객체 탐지, 세그멘테이션 등 핵심 태스크 Taxonomy 정의.
|
||||
- 실시간 객체 추적 및 공간 이해를 위한 딥러닝 기법 통합.
|
||||
### Action recognition
|
||||
- 매 video understanding.
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌**: 과거에는 필터 제작 등 수동 특징 추출(Hand-crafted features) 정책 위주였으나, 현대 정책은 데이터로부터 스스로 특징을 배우는 '딥러닝 기반 종단간 학습 정책(End-to-end)'으로 완전히 전환됨(RL Update).
|
||||
- **정책 변화(RL Update)**: 2D 이미지 분석 정책을 넘어, 최근에는 '3D 공간 지능 정책'과 '멀티모달(시각+언어) 통합 정책'이 자율주행과 에이전틱 서비스의 핵심 정책 토대가 됨.
|
||||
### Re-Identification
|
||||
- 매 person / vehicle re-id.
|
||||
|
||||
---
|
||||
### 3D vision
|
||||
- 매 NeRF, Gaussian Splatting.
|
||||
- 매 [[Automated_Mapping]] 참조.
|
||||
|
||||
- **과거 데이터와의 충돌:** 단순히 형태를 인식하는 수준에서, 현재는 [[CLIP|CLIP]]이나 멀티모달 LLM을 통해 이미지 속 상황을 '설명'하고 '추론'하는 단계로 진입.
|
||||
- **정책 변화:** Antigravity 프로젝트는 위키 문서 내의 비정형 도표나 스크린샷 데이터를 텍스트로 변환하여 지식 베이스에 통합할 때 최신 비전-언어 모델을 활용함.
|
||||
## 매 architecture history
|
||||
|
||||
---
|
||||
### CNN era (2012-2020)
|
||||
- AlexNet (2012) → 매 ImageNet revolution.
|
||||
- VGG, ResNet (skip connection), DenseNet, EfficientNet.
|
||||
- 매 inductive bias: locality + translation invariance.
|
||||
|
||||
- **과거 데이터와의 충돌:** 기하학적 매칭 중심의 전통적 CV에서 데이터 기반의 신경망 학습 모델로 패러다임 완전 전환.
|
||||
- **정책 변화:** 기술적 정확도(w1)와 윤리적 프라이버시 보호의 가중치 균형 조절.
|
||||
### ViT era (2020+)
|
||||
- ViT (Dosovitskiy 2020).
|
||||
- 매 patch + transformer.
|
||||
- 매 large data 의 dominate.
|
||||
- Swin, DeiT, MAE pretrain.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- Pattern Recognition, [[Autonomous Vehicles|Autonomous Vehicles]], [[CV_Synthesis|CV_Synthesis]], [[Artificial Intelligence (AI)|Artificial Intelligence (AI)]], [[Robotics|Robotics]]
|
||||
- **Modern Tech/Tools**: OpenCV, PyTorch/TensorFlow, YOLO, Segment Anything Model (SAM), NeRF.
|
||||
---
|
||||
### Foundation model (2021+)
|
||||
- **CLIP**: 매 image-text contrastive.
|
||||
- **DINO / DINOv2**: 매 self-supervised.
|
||||
- **MAE**: 매 masked autoencoder.
|
||||
- **SAM**: 매 segment anything.
|
||||
- **Depth Anything**: 매 universal depth.
|
||||
|
||||
---
|
||||
### Multi-modal (2023+)
|
||||
- **GPT-4V, Claude vision, Gemini**: 매 LLM + vision.
|
||||
- **LLaVA, Qwen-VL**: 매 open.
|
||||
- **Sora, Veo**: 매 video generation.
|
||||
|
||||
- [[Convolutional-Neural-Networks|Convolutional-Neural-Networks]], [[CLIP|CLIP]], Image-Processing, [[Transformer-Architecture|Transformer-Architecture]]
|
||||
- **Raw Source:** 10_Wiki/Topics/AI/Computer-Vision.md
|
||||
## 💻 패턴
|
||||
|
||||
---
|
||||
### Image classification (ViT, HuggingFace)
|
||||
```python
|
||||
from transformers import ViTImageProcessor, ViTForImageClassification
|
||||
from PIL import Image
|
||||
|
||||
- **Parent:** 10_Wiki/💡 Topics/AI
|
||||
- **Related:** [[CV_Synthesis|CV_Synthesis]], Object-Detection, CNN
|
||||
- **Raw Source:** 00_Raw/2026-04-20/[[Computer Vision|Computer Vision]].md
|
||||
processor = ViTImageProcessor.from_pretrained('google/vit-large-patch16-384')
|
||||
model = ViTForImageClassification.from_pretrained('google/vit-large-patch16-384')
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
image = Image.open('cat.jpg')
|
||||
inputs = processor(images=image, return_tensors='pt')
|
||||
outputs = model(**inputs)
|
||||
predicted_idx = outputs.logits.argmax(-1).item()
|
||||
print(model.config.id2label[predicted_idx])
|
||||
```
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
### Object detection (YOLO)
|
||||
```python
|
||||
from ultralytics import YOLO
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
model = YOLO('yolov8x.pt')
|
||||
results = model('image.jpg', conf=0.5)
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
for r in results:
|
||||
for box in r.boxes:
|
||||
print(f'{model.names[int(box.cls)]}: {box.conf.item():.2f} at {box.xyxy[0].tolist()}')
|
||||
```
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
### Segmentation (SAM)
|
||||
```python
|
||||
from segment_anything import sam_model_registry, SamPredictor
|
||||
import cv2
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
sam = sam_model_registry['vit_h'](checkpoint='sam_vit_h.pth').to('cuda')
|
||||
predictor = SamPredictor(sam)
|
||||
predictor.set_image(image)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
# 매 prompt: bbox or point
|
||||
masks, scores, _ = predictor.predict(
|
||||
box=np.array([100, 100, 400, 400]),
|
||||
multimask_output=False,
|
||||
)
|
||||
```
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
### Depth estimation (Depth Anything)
|
||||
```python
|
||||
from transformers import pipeline
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
pipe = pipeline('depth-estimation', model='depth-anything/Depth-Anything-V2-Large-hf')
|
||||
depth = pipe(image)['depth']
|
||||
depth.save('depth.png')
|
||||
```
|
||||
|
||||
### CLIP zero-shot
|
||||
```python
|
||||
import open_clip
|
||||
|
||||
model, _, preprocess = open_clip.create_model_and_transforms('ViT-L-14', pretrained='openai')
|
||||
tokenizer = open_clip.get_tokenizer('ViT-L-14')
|
||||
|
||||
candidates = ['a cat', 'a dog', 'a bird']
|
||||
text = tokenizer(candidates)
|
||||
img = preprocess(image).unsqueeze(0)
|
||||
|
||||
with torch.no_grad():
|
||||
img_feat = model.encode_image(img) / ...
|
||||
text_feat = model.encode_text(text) / ...
|
||||
similarity = (100 * img_feat @ text_feat.T).softmax(-1)
|
||||
```
|
||||
|
||||
### Pose estimation (MediaPipe)
|
||||
```python
|
||||
import mediapipe as mp
|
||||
|
||||
mp_pose = mp.solutions.pose
|
||||
with mp_pose.Pose() as pose:
|
||||
results = pose.process(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
|
||||
if results.pose_landmarks:
|
||||
for lm in results.pose_landmarks.landmark:
|
||||
print(lm.x, lm.y, lm.z, lm.visibility)
|
||||
```
|
||||
|
||||
### Tracking (ByteTrack)
|
||||
```python
|
||||
from yolox.tracker.byte_tracker import BYTETracker
|
||||
|
||||
tracker = BYTETracker(args)
|
||||
for frame in video:
|
||||
detections = detector(frame) # 매 (N, 5): xyxy + conf
|
||||
tracked = tracker.update(detections, frame_size, frame_size)
|
||||
for t in tracked:
|
||||
print(t.track_id, t.tlbr, t.score)
|
||||
```
|
||||
|
||||
### OCR (PaddleOCR)
|
||||
```python
|
||||
from paddleocr import PaddleOCR
|
||||
|
||||
ocr = PaddleOCR(use_angle_cls=True, lang='en')
|
||||
result = ocr.ocr('document.jpg', cls=True)
|
||||
for line in result[0]:
|
||||
bbox, (text, conf) = line
|
||||
print(text, conf)
|
||||
```
|
||||
|
||||
### Multi-modal (GPT-4V via API)
|
||||
```python
|
||||
from openai import OpenAI
|
||||
client = OpenAI()
|
||||
|
||||
response = client.chat.completions.create(
|
||||
model='gpt-4o',
|
||||
messages=[{
|
||||
'role': 'user',
|
||||
'content': [
|
||||
{'type': 'text', 'text': 'What objects do you see, and where are they?'},
|
||||
{'type': 'image_url', 'image_url': {'url': image_url}},
|
||||
],
|
||||
}],
|
||||
)
|
||||
print(response.choices[0].message.content)
|
||||
```
|
||||
|
||||
### Self-supervised pre-train (MAE, simplified)
|
||||
```python
|
||||
def mae_pretrain(model, image, mask_ratio=0.75):
|
||||
patches = patchify(image, patch_size=16)
|
||||
n_visible = int(len(patches) * (1 - mask_ratio))
|
||||
visible_idx = torch.randperm(len(patches))[:n_visible]
|
||||
|
||||
encoded = encoder(patches[visible_idx])
|
||||
full = insert_mask_tokens(encoded, visible_idx, total=len(patches))
|
||||
reconstructed = decoder(full)
|
||||
|
||||
loss = ((reconstructed[masked_idx] - patches[masked_idx]) ** 2).mean()
|
||||
return loss
|
||||
```
|
||||
|
||||
### NeRF (volumetric 3D)
|
||||
```python
|
||||
# 매 [[Automated_Mapping]] 참조 — 매 NeRF / Gaussian Splatting code
|
||||
```
|
||||
|
||||
## 🤔 결정 기준
|
||||
| Task | Tool |
|
||||
|---|---|
|
||||
| Classify | ViT / EfficientNet |
|
||||
| Detect | YOLOv8 / DETR / Grounding DINO |
|
||||
| Segment | SAM (open-vocab) / Mask2Former |
|
||||
| Depth | Depth Anything V2 |
|
||||
| Pose | MediaPipe / ViTPose |
|
||||
| Track | ByteTrack |
|
||||
| OCR | PaddleOCR / GPT-4V |
|
||||
| Zero-shot | CLIP / SigLIP |
|
||||
| Generate | Stable Diffusion / Flux |
|
||||
| Edge | YOLOv8n / MobileNetV4 |
|
||||
| Foundation feature | DINOv2 |
|
||||
|
||||
**기본값**: 매 task-specific SOTA + 매 CLIP / SAM 의 zero-shot fallback.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[AI]] · [[Deep-Learning]]
|
||||
- 변형: [[CNN]] · [[ViT]] · [[CLIP]] · [[SAM]] · [[DINOv2]] · [[MAE]]
|
||||
- 응용: [[Object-Detection]] · [[Bounding-Box-Regression]] · [[Automated_Mapping]] · [[Autonomous-Vehicles]] · [[Algorithmic-Biology]]
|
||||
- Adjacent: [[Multimodal-Learning]] · [[Diffusion-Models]] · [[CV_Synthesis]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 vision task. 매 multimodal product. 매 image search. 매 autonomous system.
|
||||
**언제 X**: 매 audio / pure text. 매 1D signal.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Custom CNN from scratch (small data)**: 매 pretrain 의 use.
|
||||
- **No augmentation**: 매 generalization X.
|
||||
- **ImageNet only eval**: 매 distribution shift.
|
||||
- **No domain adapt**: 매 medical / satellite 의 weak.
|
||||
- **Single model for all task**: 매 specialized 의 better.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (ImageNet, ViT, CLIP, SAM papers).
|
||||
- 신뢰도 A.
|
||||
- Related: [[CLIP]] · [[Bounding-Box-Regression]] · [[Automated_Mapping]] · [[Autonomous-Vehicles]] · [[CV_Synthesis]] · [[Algorithmic-Biology]].
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — task taxonomy + history + 매 ViT / YOLO / SAM / Depth / CLIP / GPT-4V code |
|
||||
|
||||
Reference in New Issue
Block a user