This code is used in the lectures for the SE for Media Unit for MSc AIM. The lecture pages, labs and seminars all live on the unit website and the code for them lives here.
It is expected you will use uv to run everything. Most of the notebooks are marimo notebooks, so from the root of the repo
uv sync
uv run marimo edit Lecture2/Lecture2Marimo.pyYou can also open any of the marimo notebooks in the browser using molab, see Notebooks on molab for the links. Some may not work due to the requirement of Utils being needed but you can still read the text and understand what is happening. I will try to update the requirements as soon as possible.
The notebook glossary explains the terms used in the examples, with links to papers and other sources.
Note this README.md is autogenerate by claude on update and commit so may not be 100% accurate.
The lecture numbers below follow the website, which doesn't always match the folder names (the LectureN folders stop at 7).
| Lecture | Slides | Code | Description |
|---|---|---|---|
| 1 | Slides | Lecture1, IntroToMarimo | Introduction to the unit, uv, and a first look at marimo |
| 2 | Slides | Lecture2 | Introduction to Python, numbers, strings, lists, tuples and dictionaries |
| 3 | Slides | Lecture3 | Sequence, selection and iteration, functions and exceptions |
| 4 | Slides | Lecture4 | Object oriented programming, accessors, aggregation, inheritance and operator overloading |
| 5 | Slides | Lecture5, NumPyForML | Using NumPy |
| 6 | Slides | Lecture6, MatplotlibForML | Matplotlib, Pandas and Polars |
| 7 | Slides | Lecture7, PyTorchForML | PyTorch and tensors |
| 8 | Slides | LinearModel, Neuron, Checkpoints | ML workflows with PyTorch |
| 9 | Slides | Classification | Simple, binary and multi-class classification |
| 10 | Slides | MNIST, Packages | Data loaders, the python path and the MNIST dataset |
These build on the lectures and are the ones I use in the later machine learning sessions.
| Folder | Description |
|---|---|
| NumPyForML | Five notebooks on the NumPy you actually need for the ML demos |
| MatplotlibForML | Figures, plots, images and saving output |
| PlotlyForML | Interactive plots with Plotly Express and Graph Objects, training curves and HTML export |
| PyTorchForML | Tensors, autograd, modules, inference, data and saving models, plus a notebook on activation functions |
| TorchVisionForML | Images, transforms, augmentation and datasets with torchvision |
| TorchAudioForML | Waveforms, features, augmentation and audio datasets |
| TorchCodecForML | Decoding video and audio into tensors with TorchCodec, clip sampling and datasets |
| Neuron | A neural network from scratch in plain Python |
| LinearModel | Fitting a linear model with PyTorch |
| Checkpoints | Saving and restoring training checkpoints |
| Classification | Simple, binary and multi-class classification |
| MNIST | The MNIST dataset, data loaders, training, and a Qt sketch pad to test the model (Sketch) |
| ASL | American Sign Language recognition in three parts (dense, CNN, data augmentation) with a real-time webcam demo in RealTimeCapture |
| FreeSpokenDigits | The Free Spoken Digits audio dataset in three parts (data, data loaders, training) and a live microphone demo |
| PreTrainedModels | Using pre-trained ImageNet models and transfer learning |
| DataToTensors | Breaking down an ML problem, then looking at the shape and form of the data and getting it into tensors |
| DataLeakage | Data leakage and why we need group splits |
| EvaluationOfResults | Baselines and metrics for evaluating image results, and how to present them |
| ExperimentTracking | TensorBoard and MLflow, as standalone scripts and within marimo |
| ImageToImage | U-Net image-to-image learning for denoising, super resolution and pet segmentation |
| PointCloudsAndMeshNet | Seven lessons on point clouds, from surface sampling to PointNet classification, segmentation and ModelNet10 |
| TextProcessingRNN | Text processing with recurrent neural networks (work in progress) |
| CloudTraining | The ML DevOps cycle from prototype to container to inference endpoint, using podman to simulate the cloud |
The lab and seminar write-ups are on the unit website, this is the code that goes with them.
| Folder | Description |
|---|---|
| Lab1 | A small maths quiz program and images for the first lab |
| ImageLab | Solution for Lab 4 An Image Class |
| Seminars/Arguments | Starter and solution code for the Command Line Arguments seminar, using sys.argv, argparse and click |
| Seminars/Files | Code for the File IO seminar, reading and writing text and CSV files |
| Folder | Description |
|---|---|
| Utils | Shared helpers used by the notebooks (downloading data, picking a device, accuracy, checking if we are in the lab) |
| IntroToMarimo | An introduction to marimo notebooks and their UI elements |
| Packages | How Python finds packages and why the notebooks use sys.path.append("../") to get at Utils |
| scripts | A pre-commit hook I use to export the marimo notebooks to markdown |
Each of these links opens the notebook from GitHub in molab, the hosted version of marimo, so you can try things out without installing anything. Some of them won't work there as they need local hardware or tools (the microphone, webcam, Qt and podman demos for example), and the bigger training runs will be a lot slower than on a lab machine with a GPU.