→ From Coder to Shipper
From Coder to Shipper · Batteries included

Python's Great Libraries

numpy, matplotlib, scipy, Pillow, OpenCV, PyTorch — the ready-made toolboxes that turn heavy math and data work into a single import. You pick the tool; the AI writes the code.

← / → to navigate · EN/VI switch below

Big picture

Python's ecosystem: batteries included

The hard parts — fast math on big data, plotting, image processing, neural networks — are already written, battle-tested, and free. You import them; you don't build them.

The heavy lifting is already done

Fast math on a million numbers, drawing charts, editing images, training neural networks — each is a mature, battle-tested library.

One import = one toolbox

import numpy gives fast arrays; from PIL import Image gives image editing; import torch gives deep learning. The import line tells you the job of the whole file.

You pick the job — AI writes the code

You don't memorize thousands of functions. You know which library does what, then you ask the AI for code and check the result.

Layered, not isolated

NumPy is the base; the others build on or beside it. Knowing the layering explains why some libraries feel fast, some scientific, some visual.

How you'll use them

A map of jobs, not a list of functions

This deck is a job map. Each library gets one clear job and a tiny taste of its API — just enough to recognize it in code the AI hands you.

What you DON'T need

No memorizing APIs, no writing matrix math by hand, no understanding how a neural network trains internally. Those are the library's job — and the AI's job.

What you DO need

A map of six jobs: arrays, charts, science, images, vision, deep learning. When a problem lands, you name the job, pick the library, and hand the rest to the AI.

Getting a library

pip install → import → call

Every library in this deck follows the same three steps. The aliases (np, plt, cv2, torch) are conventions — you'll recognize them everywhere.

get.py
# first time on this machine: install (projects list this in requirements.txt)
# pip install numpy pillow matplotlib

# every file that uses them starts like this:
import numpy as np                  # alias: np
from PIL import Image               # pull in the Image class
import matplotlib.pyplot as plt     # alias: plt

print(np.mean([1, 2, 3]))           # 2.0 — toolbox, ready

requirements.txt in real projects is just a list of pip installs. If an AI answer starts with an import you don't know, that's your first question: 'what does this do?'

01
Part 1

NumPy — the fast base

The foundation of the whole data stack: fast arrays and vectorized math. Everything else speaks its language.

Part 1 · NumPy

Fast multi-dimensional arrays — the base everyone builds on

NumPy's job is one: hold numbers in a grid and do math on the whole grid at once.

The ndarray

A fast, fixed-size grid of numbers: one row, a table, or a whole image (rows × cols × 3). Python's lists, but arranged for speed.

Vectorized math

a * b multiplies two arrays element by element in one line — no loops. That's the 'fast': C-speed math over millions of numbers.

The foundation

Matplotlib, SciPy, OpenCV and PyTorch all exchange data as NumPy arrays. Read one [rows, cols] array and you can read most of the data stack.

Part 1 · a taste of NumPy

One expression instead of a loop

The essence of NumPy: describe the whole operation, not each element. That's the vectorized way.

numpy.py
import numpy as np

a = np.array([1, 2, 3, 4])
b = np.array([10, 20, 30, 40])

print(a * b)      # [ 10  40  90 160]  ← element by element
print(a.sum())    # 10
print(a.mean())   # 2.5

# an image = one array: rows × cols × 3 color channels
pixels = np.zeros((100, 100, 3))

np.array builds the array; .sum(), .mean() are the everyday calls. Line 11 is the kicker: an entire image is just one array.

Part 1 · why it's fast

One expression instead of a loop

The slow way (plain Python)

total = 0; for x in a: total = total + x — Python checks types and bounds element by element. Fine for 100 numbers, painful for 10 million.

The NumPy way

a.sum() — one call, the whole array processed at C speed. Same result, often 100× faster. The array is the point; the loop disappears.

02
Part 2

Matplotlib — make it visible

The classic plotting library: from a list of numbers to a shareable chart in three calls.

Part 2 · Matplotlib

Turn data into pictures

The fastest route from 'list of numbers' to 'chart I can share'.

Charts from data

Give it two lists (x, y) and it draws a line. Bars, scatter, histograms — the standard ways to look at numbers.

The plt alias

import matplotlib.pyplot as plt is the convention you'll see everywhere: plt.plot, plt.bar, plt.title, plt.show.

You mostly read its output

As a shipper you'll mostly look at the chart it produces — and occasionally ask the AI to tweak: 'make it a bar chart', 'add a title', 'export to PNG'.

Part 2 · a taste of Matplotlib

Two lists in, a chart out

The whole API is 'describe the picture': the data, the style, the window.

plot.py
import matplotlib.pyplot as plt

days = [1, 2, 3, 4, 5]
signups = [12, 19, 17, 28, 35]

plt.plot(days, signups)    # draw the line
plt.title("Daily signups")
plt.show()                 # open the window

Three calls and a chart exists. This exact shape shows up in every data analysis you'll ever review.

03
Part 3

SciPy — the science kit

Statistics, optimization, signals, linear algebra — the serious-math shelf, built on NumPy arrays.

Part 3 · SciPy

Serious math, one level above NumPy

SciPy = scientific computing on top of NumPy. Same arrays in and out, but with the hard formulas already inside.

scipy.stats

Distribution math: mean, std, confidence intervals, hypothesis tests. When you ask 'is this result significant?', the answer comes from here.

scipy.optimize

Find the best parameters: minimize a cost, fit a curve to data. The engine behind 'make the model fit'.

scipy.signal

Frequencies and filters: clean a noisy sensor signal, find the dominant frequency. The audio and vibration toolkit.

scipy.linalg

Linear algebra beyond NumPy's basics: decompositions, eigenvalues. The heavy-duty math shelf — all speaking NumPy arrays.

Part 3 · a taste of SciPy

Statistics as a function call

SciPy takes lists or arrays and gives back numbers — the same data, one more level of math.

stats.py
from scipy import stats

temps = [21.5, 22.1, 20.9, 23.0, 22.4, 21.8, 22.6]
d = stats.describe(temps)

print(d.mean)          # 22.1 — the average
print(d.std)           # 0.6  — how much it varies
print(d.min, d.max)    # 20.9 23.0

One describe() call hands you the full statistical summary of a dataset. No loops, no formulas.

04
Part 4

Pillow — everyday images

The everyday image toolkit: open, resize, crop, convert, save. The one your web app will actually use.

Part 4 · Pillow

The everyday image toolkit

Pillow (PIL) does the boring 95% of image work: open it, tweak it, save it. No GPU, no model — just fast, reliable pixels.

Open & save

Image.open('a.jpg') reads almost any format — JPEG, PNG, WebP, GIF; .save() writes it back. The workhorse of any image endpoint.

Resize & thumbnail

img.resize((200, 200)) sets an exact size; img.thumbnail((200, 200)) shrinks while keeping the ratio. The two calls behind every 'upload a photo' feature.

Crop & convert

img.crop((x1, y1, x2, y2)) cuts a region; img.convert('L') switches to grayscale. Compose them into real image pipelines.

Most relevant to you

Avatars, product photos, generated thumbnails, uploaded files — for a VPS web app, Pillow is the image library you'll meet first and use most.

Part 4 · a taste of Pillow

Open, resize, save — the daily three

Everything else (crop, rotate, filters) is the same shape: open it, call a method, save it.

img.py
from PIL import Image

img = Image.open("photo.jpg")      # open it
img = img.resize((400, 400))       # new size
thumb = img.copy()
thumb.thumbnail((100, 100))        # keep ratio
img.save("out.jpg")                # save it
print(img.size)                    # (400, 400)

Eight lines, and a photo is resized, thumbnailed and saved — the core of most 'image upload' features.

05
Part 5

OpenCV — computer vision

Image and video processing at scale: filters, transforms, detection — let the computer see.

Part 5 · OpenCV

Let the computer see

Image and video processing at scale — filters, transforms, and detection, frame by frame.

Fast pixel operations

Blur, threshold, edge detection, rotation — implemented in optimized C, so it stays fast on big images and whole video streams.

Detection & features

Find faces, corners, contours; match shapes. The classical-vision toolkit — what came before deep learning took over.

The cv2 alias, BGR order

import cv2 is the convention. One quirk to remember: it reads images as BGR (blue–green–red), not RGB — a classic source of color bugs.

Part 5 · a taste of OpenCV

Vision as a few array calls

The shape: load an image, transform it, detect something. That's the whole vocabulary.

cv.py
import cv2

img = cv2.imread("street.jpg")     # loads as a NumPy array!
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
blur = cv2.GaussianBlur(gray, (5, 5), 0)

faces = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
found = faces.detectMultiScale(gray, 1.1)
print(len(found), "faces found")

Line 3 is the layering in action: OpenCV hands you a NumPy array. Filters and detection are single calls on that array.

06
Part 6

PyTorch — where AI comes from

The deep learning framework: tensors, autograd, and the training loop behind every AI model.

Part 6 · PyTorch

Where the AI models come from

The deep learning framework: tensors, automatic gradients, and the loop that trains models.

Tensors

Like NumPy arrays, but they also live on GPUs: torch.tensor([1, 2, 3]). The data type of deep learning.

Autograd

PyTorch records your math as you compute, so it can compute gradients — 'how much should each weight change'. That signal makes training possible.

Models & training

A model is a chain of tensor operations; training is thousands of steps of predict → measure error → nudge weights. Every LLM and image model is made this way.

Part 6 · a taste of PyTorch

Tensors + autograd in seven lines

You'll rarely write this yourself — but recognizing 'this is training a model' is the skill.

torch.py
import torch

x = torch.tensor([1.0, 2.0, 3.0], requires_grad=True)
y = (x * x).sum()         # 1 + 4 + 9 = 14
y.backward()              # compute the gradient
print(x.grad)             # [2. 4. 6.]  ← d(x²)/dx = 2x

A model in embryo: a computation, and the gradient that says which way to adjust. Training = repeat this, thousands of steps, at scale.

07
Part 7

The big picture: layering & choosing

The deck in one view: who sits on whom, which job belongs to which library, and what you'll actually use.

Part 7 · the stack

NumPy at the bottom — everything else builds on it

When a library says 'works with arrays', it means NumPy arrays. Data flows down: your app calls a high-level function, which does fast NumPy math underneath.

PyTorchdeep learning — tensors & models
SciPystats · optimization · signals
Matplotlibcharts & plots
Pilloweveryday image editing
OpenCVvision — filters · detection
NumPythe base — fast multi-dimensional arrays, vectorized math
Pythonthe language itself

your app → high-level call → fast NumPy math underneath

Part 7 · the map

Which library for which job

Memorize the import lines, not the functions — the import is the job description.

LibraryIts one jobYou'll spot it when
NumPyFast multi-dimensional arrays & vectorized mathimport numpy as np — most data stacks start here
MatplotlibCharts: lines, bars, histograms from dataimport matplotlib.pyplot as plt
SciPyStats, optimization, signals, linear algebrafrom scipy import stats / optimize
PillowEveryday images: open, resize, crop, convertfrom PIL import Image
OpenCVVision: filters, detection, video framesimport cv2
PyTorchDeep learning: tensors, autograd, trainingimport torch
Part 7 · your reality

What your web app actually reaches for

Most projects never touch the heavy stack — and that's correct. Match the tool to the job.

Web app → Pillow

Uploads, avatars, thumbnails, generated images: Pillow is the workhorse. Small install, fast, fits a VPS perfectly.

Data questions → NumPy + Matplotlib

Analyze a CSV export, chart a decision: NumPy does the math, Matplotlib makes it visible. SciPy joins when the math gets scientific.

Vision / AI → OpenCV or PyTorch

Specific projects only: detect objects (OpenCV) or run models (PyTorch — often via an API, not on your VPS). Know they exist; that's enough.

Part 7 · the workflow

Using a library with AI, step by step

The same four moves you use everywhere in this course — now pointed at library code.

  1. 1

    Name the job, not the function

    Tell the AI the outcome: 'resize uploaded photos to 400px and save thumbnails.' The job picks the library — Pillow, in this case.

  2. 2

    Check the imports first

    The first line of any AI answer: what does it import? from PIL import Image → image job. import torch → heavy ML job — question why.

  3. 3

    Mind the install cost

    Pillow is a tiny install; PyTorch is gigabytes with a GPU stack. Ask what it must pip install before you say yes — on a VPS, disk and RAM are real.

  4. 4

    Run it, look at the output

    Save the result and look: a thumbnail at the right size, a chart with the right numbers, a gradient of [2. 4. 6.]. Output is the truth.

Six libraries, one habit: know the job of each, and let the AI do the rest.
— the course

NumPy. Charts. Science. Images. Vision. AI. That's the toolbox.

Next: put these to work in a real project. Unfamiliar import? You know the move: name the job, check the install cost, run the output.