How shradha-khapra/ai-nst-project works
This repository implements AdaIN neural style transfer with a Flask upload-and-render interface and a separate model-training workflow. Inference accepts content and style images plus an alpha blend, encodes both, normalizes content features using style statistics, decodes and saves the result for display. Training builds paired image batches, optimizes the decoder against content and style losses, and saves checkpoints. Source excerpts establish the web and training calls; README has no further capability detail, so assets and unsampled routes are not expanded.
Main entry points: train.py Training loop · app.py Flask routes · models.py VGG encoder · utils.py Image dataset
Components 18
Web inference
- Flask routes
NST_Code/app.py - Image uploads
NST_Code/app.py - Result page
NST_Code/templates/index.html
Style transfer
- Inference transfer
NST_Code/app.py - VGG encoder
NST_Code/utils/models.py - Decoder
NST_Code/utils/models.py - AdaIN statistics
NST_Code/utils/utils.py - Image encoding
NST_Code/app.py
Model training
- Training loop
NST_Code/train.py - Image dataset
NST_Code/utils/utils.py - Training transforms
NST_Code/utils/utils.py - Training losses
NST_Code/train.py
Image and model data
- Image collections
NST_Code/content_data - Style collections
NST_Code/style_data - Uploaded and output images
NST_Code/static/uploads - Model weights
NST_Code/experiment/final_exp/decoder_final.pth - VGG weights
NST_Code/vgg_normalised.pth
Other components
- User
Connections 19
- User → Flask routes: submits images
NST_Code/app.py - Flask routes → Image uploads: saves uploads
NST_Code/app.py - Flask routes → Inference transfer: runs transfer
NST_Code/app.py - Inference transfer → VGG encoder: encodes images
NST_Code/app.py - Inference transfer → AdaIN statistics: normalizes features
NST_Code/app.py - Inference transfer → Decoder: decodes features
NST_Code/app.py - Flask routes → Image encoding: saves result
NST_Code/app.py - Flask routes → Uploaded and output images: reads and writes
NST_Code/app.py - Flask routes → Result page: renders page
NST_Code/app.py - Flask routes → User: serves result
NST_Code/app.py - Training loop → Image dataset: constructs datasets
NST_Code/train.py - Training loop → Training transforms: gets transforms
NST_Code/train.py - Training loop → VGG encoder: encodes batches
NST_Code/train.py - Training loop → Decoder: trains decoder
NST_Code/train.py - Training loop → AdaIN statistics: normalizes features
NST_Code/train.py - Training loop → Training losses: computes losses
NST_Code/train.py - Image dataset → Image collections: loads images
NST_Code/utils/utils.py - Training loop → Model weights: loads checkpoint
- VGG encoder → VGG weights: loads weights
NST_Code/utils/models.py