How bhooyas/nst works
Project Type and Purpose
• This is a hybrid machine-learning application that supports both model training/inference in Python (CLI) and real-time inference in the browser (UI).
• It implements Neural Style Transfer (NST) using PyTorch for training and ONNX for client-side inference via JavaScript.
Key Architectural Components (from file tree and README)
• Data & Configuration
• get_dataset.sh – shell script to fetch training data
• config.py – hyperparameters & paths
• Training Pipeline (Python)
• train.py – orchestrates data loading, model instantiation, optimization (uses model.py & optim_nst.py)
• model.py – defines the NST network
• optim_nst.py – custom loss functions and optimizer wrappers
• Output: .safetensors checkpoints in /models
• ONNX Conversion
• onnx-convertor.py – converts trained .safetensors → .onnx (drops into UI/models)
• Inference Pipelines
• inference.py – static-image inference (PyTorch)
• inference_webcam.py – real-time webcam inference (PyTorch + OpenCV)
• Web UI (Client-side)
• UI/index.html, rain_princess.html, starry_night.html – static pages
• UI/models/*.onnx – ONNX style models (rain_princess.onnx, starry_night.onnx)
• UI/script.js – loads ONNX runtime-web, handles image upload and inference in browser
• UI/style.css – styling