Skip to main content...
Python + Classical CV — the Catalog Tool
25 min

Day 1: Python environment & idiom I: venv/uv, project structure

You already know how to program. This stage teaches Python's idiom and its numeric stack — not programming itself.

Why FitXpert, and why Python

Every stage of this roadmap ships one working increment of FitXpert, a virtual trial room for apparel retail. Today's target — the Catalog Tool — is small on purpose: a garment photo goes in, a clean, background-removed, normalized cutout comes out, callable from a CLI and from one FastAPI endpoint. It's the first rung of a ladder that ends, 230 days from now, in a diffusion-based try-on system serving behind a NestJS gateway.

You're a senior backend engineer, so this stage is not 'learn to code' — it's learning Python's idiom (the patterns experienced Python developers reach for) and the numeric stack (NumPy, Pandas, OpenCV) that every AI library in this roadmap is quietly built on top of. PyTorch tensors, pandas DataFrames, OpenCV images — all of them are NumPy arrays with extra behavior bolted on. Get comfortable with the array as a mental model this week and the rest of the roadmap reads faster.

Why Python won the AI ecosystem

Python itself is slow for tight numeric loops — the ecosystem doesn't fight that, it routes around it. NumPy, PyTorch, and OpenCV are thin Python interfaces over C/C++/CUDA code; you write Python, but the actual number-crunching runs in compiled code. Python's job is to be the readable glue language wiring fast components together. That division of labor is why 'vectorize instead of loop' (Day 4) will be the single highest-leverage habit you build this week.

venv vs uv

Every Python project needs an isolated environment — otherwise installing one project's dependencies silently breaks another's. venv is the standard-library way: it creates a private site-packages folder and a python/pip pair scoped to it. uv (from Astral) is a modern, Rust-built replacement that does the same job — plus dependency resolution and locking — an order of magnitude faster, and is what this roadmap uses going forward.

Project setup with uv (falls back to venv+pip if you prefer)
# uv — fast, modern
uv init fitxpert-catalog
cd fitxpert-catalog
uv add numpy pandas matplotlib opencv-python fastapi uvicorn
uv run python -c "import cv2; print(cv2.__version__)"

# stdlib equivalent
python -m venv .venv
source .venv/bin/activate   # .venv\Scripts\activate on Windows
pip install numpy pandas matplotlib opencv-python fastapi uvicorn

Project structure

Python's convention closest to a backend engineer's instincts is the src layout: an installable package under src/, tests alongside it, dependencies declared in pyproject.toml (Python's package.json). This avoids the classic beginner trap of accidentally importing files from the current working directory instead of the installed package.

Src layout for the Catalog Tool
fitxpert-catalog/
  pyproject.toml
  src/
    catalog/
      __init__.py
      pipeline.py     # background removal -> resize -> normalize
      cli.py           # CLI entrypoint (Day 12)
      api.py           # FastAPI endpoint (Day 13)
  tests/
    test_pipeline.py

Key terms

Virtual environment
An isolated set of installed packages + interpreter, scoped to one project so dependencies don't collide across projects.
uv
A fast, Rust-built Python package/project manager — creates venvs, resolves and locks dependencies, and runs scripts.
pyproject.toml
Python's standard project metadata and dependency file — the rough equivalent of package.json.
src layout
Placing the installable package under src/ so it must be explicitly installed/imported rather than accidentally picked up from the working directory.

Before moving on, you should be able to

Why can Python-based ML code (NumPy, PyTorch) be fast despite Python itself being a slow language?

We use cookies

We use cookies to enhance your browsing experience, serve personalized content, and analyze our traffic. By clicking "Accept All", you consent to our use of cookies. Learn more

    Day 1: Python environment & idiom I: venv/uv, project structure | RBTechIconX