🎯

input → pre-trained model → output — The Essence of AI Inference in One Line

Forget STFT and masking — the model does exactly one thing: take input, produce output

The Core: The Neural Network Does Exactly One Line

Look at the source separation pipeline again:

song.mp3
  ↓ torchaudio.load()        ← file I/O (math)
  ↓ torch.stft()             ← Fourier transform (math)
  ↓ model(magnitude)         ← ★ ONLY neural network ★
  ↓ magnitude × mask         ← matrix multiply (math)
  ↓ torch.istft()            ← inverse Fourier (math)
vocals.wav

model(magnitude) — this one line is the only part using the neural network.

Everything else is deterministic math.

Pattern: input → model → output

All AI inference follows this structure:

output = model(input)

Example 1: Image Classification (Simplest)

output = model(image)  # [28×28 pixels] → [10 probabilities]
predicted = output.argmax().item()  # → 7

Example 2: Sound Classification

result = classifier("dog_bark.wav")
# → {'label': 'Dog', 'score': 0.98}

Inside: wav → mel spectrogram → model() → 527 class probabilities

Example 3: Speech Recognition

result = model.transcribe("speech.mp3")
# → "Hello, how are you?"

Inside: audio → mel spectrogram → model() → token sequence → text

Example 4: Source Separation

sources = apply_model(model, wav)
vocals = sources[3]  # 4 stems, index 3 = vocals

Inside: wav → chunks → STFT → model() → masks → apply → ISTFT

Example 5: Text-to-Speech

tts.tts_to_file(text="Hello", language="en", file_path="hello.wav")

Inside: text → phonemes → model() → audio tokens → vocoder → wav

Common Pattern

Task input model() output
Image classification pixels CNN class probabilities
Sound classification mel spectrogram AST 527 categories
Speech recognition mel spectrogram Whisper token sequence
Source separation spectrogram Demucs masks
TTS phonemes XTTS audio tokens

Pre/post-processing differs per task, but the core is always model(input) — one line.

Key Concepts

1

model = load_pretrained("name") — download pre-trained weights from HuggingFace/GitHub

2

input = preprocess(raw_data) — STFT, tokenizing, mel transform, etc. (all math, not neural net)

3

output = model(input) — ★ the ONLY part using the neural network ★

4

result = postprocess(output) — ISTFT, decoding, vocoder, etc. (all math)

Use Cases

Understanding AI inference — identifying the one neural network line in complex pipelines Using pre-trained models — getting results with just model(input), no training needed Model size vs performance — understanding 60K params (MNIST) vs 84.2M (RoFormer)