f8b21af4be
10_Wiki/Topics 대규모 정리: - 오류 캡처/미완성 stub 문서 227개 제거 - 교차폴더 중복 43클러스터 병합 (63파일 → redirect) - 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건 - 카테고리 MOC 6개 신규 생성 - Graph 섹션 미해결 related-keyword 링크 10,058건 제거 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
155 lines
5.4 KiB
Markdown
155 lines
5.4 KiB
Markdown
---
|
|
id: wiki-2026-0508-noise-reduction-in-ai
|
|
title: Noise Reduction in AI
|
|
category: 10_Wiki/Topics
|
|
status: verified
|
|
canonical_id: self
|
|
aliases: [Denoising, Noise Suppression, Audio Denoising, Image Denoising, Label Noise]
|
|
duplicate_of: none
|
|
source_trust_level: A
|
|
confidence_score: 0.9
|
|
verification_status: applied
|
|
tags: [denoising, audio, image, label-noise, signal-processing]
|
|
raw_sources: []
|
|
last_reinforced: 2026-05-10
|
|
github_commit: pending
|
|
tech_stack: { language: Python, framework: PyTorch/torchaudio }
|
|
---
|
|
|
|
## 한 줄
|
|
오디오/이미지 신호의 노이즈 제거(전통 DSP + DNN)와 학습 데이터의 라벨 노이즈 처리(robust loss, 자가-학습)를 통합 다룬다.
|
|
|
|
## 핵심
|
|
- **오디오 전통**: spectral subtraction, Wiener filter, MMSE-LSA — 정상 잡음 가정.
|
|
- **오디오 DNN (2026)**: RNNoise (모바일 RT), Demucs v4 (음원 분리/디노이즈), DeepFilterNet, NSNet2, Meta's Voicebox.
|
|
- **이미지 전통**: BM3D (블록 매칭+3D 변환), NLM (non-local means), wavelet thresholding.
|
|
- **이미지 DNN**: DnCNN, Restormer, NAFNet — 합성 가우시안/실세계.
|
|
- **라벨 노이즈**: symmetric/asymmetric flip, instance-dependent. 처리: GCE/SCE loss, co-teaching, confident learning, label smoothing.
|
|
|
|
## 💻 패턴
|
|
|
|
```python
|
|
# 1) Spectral subtraction (오디오)
|
|
import numpy as np
|
|
import librosa
|
|
|
|
def spectral_subtract(y, sr, noise_clip, n_fft=512, alpha=2.0, beta=0.01):
|
|
S = librosa.stft(y, n_fft=n_fft)
|
|
N = np.mean(np.abs(librosa.stft(noise_clip, n_fft=n_fft)) ** 2, axis=1, keepdims=True)
|
|
P = np.abs(S) ** 2
|
|
P_clean = np.maximum(P - alpha * N, beta * N)
|
|
S_clean = np.sqrt(P_clean) * np.exp(1j * np.angle(S))
|
|
return librosa.istft(S_clean)
|
|
```
|
|
|
|
```python
|
|
# 2) RNNoise (실시간) — 파이썬 바인딩
|
|
# pip install pyrnnoise
|
|
from pyrnnoise import RNNoise
|
|
denoiser = RNNoise(sample_rate=48000)
|
|
clean_chunks = [denoiser.process_chunk(chunk) for chunk in audio_chunks_480]
|
|
```
|
|
|
|
```python
|
|
# 3) Demucs v4로 보컬/노이즈 분리
|
|
# pip install demucs
|
|
import torch, torchaudio
|
|
from demucs.pretrained import get_model
|
|
from demucs.apply import apply_model
|
|
|
|
model = get_model("htdemucs").cpu().eval()
|
|
wav, sr = torchaudio.load("noisy.wav")
|
|
with torch.no_grad():
|
|
sources = apply_model(model, wav.unsqueeze(0), split=True)[0]
|
|
# sources: drums/bass/other/vocals
|
|
```
|
|
|
|
```python
|
|
# 4) BM3D (이미지)
|
|
# pip install bm3d
|
|
import bm3d, numpy as np
|
|
clean = bm3d.bm3d(noisy_img.astype(np.float32) / 255.0,
|
|
sigma_psd=25/255, stage_arg=bm3d.BM3DStages.ALL_STAGES)
|
|
```
|
|
|
|
```python
|
|
# 5) DnCNN (잔차 학습 디노이저)
|
|
import torch.nn as nn
|
|
class DnCNN(nn.Module):
|
|
def __init__(self, depth=17, ch=64):
|
|
super().__init__()
|
|
layers = [nn.Conv2d(3, ch, 3, padding=1), nn.ReLU(inplace=True)]
|
|
for _ in range(depth - 2):
|
|
layers += [nn.Conv2d(ch, ch, 3, padding=1), nn.BatchNorm2d(ch), nn.ReLU(inplace=True)]
|
|
layers += [nn.Conv2d(ch, 3, 3, padding=1)]
|
|
self.net = nn.Sequential(*layers)
|
|
def forward(self, x):
|
|
return x - self.net(x) # residual: predict noise
|
|
```
|
|
|
|
```python
|
|
# 6) Generalized Cross Entropy (라벨 노이즈에 강건)
|
|
import torch, torch.nn.functional as F
|
|
def gce_loss(logits, target, q=0.7):
|
|
p = F.softmax(logits, dim=-1)
|
|
pt = p.gather(1, target.unsqueeze(1)).squeeze(1).clamp(min=1e-7)
|
|
return ((1 - pt ** q) / q).mean()
|
|
```
|
|
|
|
```python
|
|
# 7) Confident Learning으로 라벨 오류 추정
|
|
# pip install cleanlab
|
|
from cleanlab.classification import CleanLearning
|
|
from sklearn.linear_model import LogisticRegression
|
|
cl = CleanLearning(clf=LogisticRegression(max_iter=1000))
|
|
cl.fit(X, y_noisy)
|
|
issues = cl.find_label_issues(X, y_noisy) # bool mask of suspect labels
|
|
```
|
|
|
|
```python
|
|
# 8) Co-teaching (두 네트워크 상호 small-loss 샘플 교환)
|
|
def co_teaching_step(net1, net2, x, y, forget_rate, opt1, opt2):
|
|
l1 = F.cross_entropy(net1(x), y, reduction="none")
|
|
l2 = F.cross_entropy(net2(x), y, reduction="none")
|
|
k = int((1 - forget_rate) * len(y))
|
|
idx1 = l1.argsort()[:k]; idx2 = l2.argsort()[:k]
|
|
# 서로 작은 loss 샘플로 업데이트
|
|
opt1.zero_grad(); F.cross_entropy(net1(x[idx2]), y[idx2]).backward(); opt1.step()
|
|
opt2.zero_grad(); F.cross_entropy(net2(x[idx1]), y[idx1]).backward(); opt2.step()
|
|
```
|
|
|
|
## 결정 기준
|
|
|
|
| 상황 | 추천 |
|
|
|---|---|
|
|
| 음성 통화 RT, 모바일 | RNNoise |
|
|
| 오프라인 고품질 음원 분리 | Demucs v4 |
|
|
| 가우시안 노이즈 이미지 | BM3D (전통), Restormer (DL) |
|
|
| 실세계 카메라 노이즈 | NAFNet, paired data fine-tune |
|
|
| 30%+ 라벨 노이즈 | Co-teaching, GCE |
|
|
| 적은 라벨 노이즈 (<10%) | label smoothing + early stop |
|
|
|
|
## 🔗 Graph
|
|
- 부모: [[Computer Vision]]
|
|
- 라벨: [[Label Noise]], [[Confident Learning]]
|
|
|
|
## 🤖 LLM 활용
|
|
- 노이즈 유형 분류 (정상/비정상/부르스트) → 알고리즘 추천.
|
|
- 라벨 노이즈 패턴 (symmetric vs asymmetric) 진단 → loss 선택.
|
|
- 디노이저 하이퍼파라미터 튜닝 가이드.
|
|
|
|
## ❌ 안티패턴
|
|
- spectral subtraction에서 alpha 너무 크게 → musical noise.
|
|
- DnCNN을 합성 가우시안으로만 학습 → 실세계에서 실패.
|
|
- 라벨 노이즈 무시하고 hard CE만 사용.
|
|
- co-teaching에서 forget_rate를 노이즈율과 동기화 안 함.
|
|
|
|
## 🧪 검증
|
|
- 오디오: PESQ, STOI, SI-SDR.
|
|
- 이미지: PSNR, SSIM, LPIPS.
|
|
- 라벨: clean test set 성능 + 의심 라벨 audit.
|
|
|
|
## 🕓 Changelog
|
|
- 2026-05-08 Phase 1 자동 생성
|
|
- 2026-05-10 Manual cleanup — house style 적용
|