100 beginner machine learning projects with runnable Python code, tests and honest case studies. By Networkers Home, Bangalore.
This project demonstrates a small, deterministic, pedagogical approximation of image “style transfer” using only numpy and scikit-learn built-in data. It is NOT a neural style transfer implementation (no deep network or optimisation loop). Instead it shows how simple statistics of image features (means and variances of filtered responses) can be matched to transfer a coarse “style” while preserving content structure. The code is intentionally small and deterministic so students can read and extend it.
This project uses the built-in sklearn digits dataset (8×8 greyscale images) as both content and style images. This is a tiny, synthetic stand-in for larger photographs. The README is explicit about this limitation: the digits dataset is not representative of general photographic content and the method here is a simplified statistical transfer (affine match of simple filter responses), not neural feature matching.
Run:
python project.py
It prints a JSON object with a few numerical metrics and provenance values (means of content/style images). The generated image is returned as a numpy array inside the process (not written to disk) and a small textual summary is printed via the JSON output.
Run pytest in the project directory (pytest will run the included test_project.py which checks API shape, metric ranges, determinism and a conservative metric floor):
pytest -q
Measured by running python project.py (seed 42) on 2026-10-23; the tests in test_project.py assert the floor.
| Metric | Value |
|---|---|
| content_index | 1245 |
| style_index | 220 |
| content_image_mean | 0.2773 |
| style_image_mean | 0.3369 |
| content_mse | 0.0001 |
| content_corr | 0.9999 |
| relative_change | 0.0212 |
| alpha | 0.8500 |
This demonstration uses 8×8 greyscale digit images from sklearn as a stand-in for photographs and does not use a convolutional neural network. The style method is a simple affine match of low-level filter statistics; it cannot reproduce complex texture or semantic style transfer. The dataset and algorithm are chosen for pedagogy and determinism rather than visual fidelity.
Potential extensions for students: replace the feature extractor with deep features from a permitted pretrained network (if allowed in another environment), run optimisation in pixel space, support RGB images and larger resolutions, or implement iterative neural-style optimisation using appropriate deep-learning frameworks and licensed pretrained weights.
Full case study, build steps and evaluation checks: Image style transfer on networkershome.com
Built by Networkers Home · Learn the skills in the AI Engineer Course · Part of 100 AI projects with code