How minivision-ai/photo2cartoon works
Photo2Cartoon converts aligned portrait faces into cartoon-style images and also provides model training and ONNX testing. The documented preparation workflow detects and aligns faces, crops them, and removes backgrounds; inference preprocesses a portrait, applies the trained generator, and saves an image. Training uses unpaired photo/cartoon datasets and combines adversarial, cycle, identity, attention, and face-ID objectives. Edges are limited to relationships visible in excerpts or stated in the README; ONNX internals were not sampled.
Main entry points: UGATIT_sadalin_hourglass.py UGATIT trainer · predict.py Prediction entry · preprocess.py Face preprocessing · data_process.py Dataset preparation
Components 17
Data preparation
- Dataset preparation
data_process.py - Face preprocessing
utils/preprocess.py - Face alignment
utils/face_detect.py - Portrait segmentation
utils/face_seg.py
Cartoon inference
- Prediction entry
predict.py - Inference preprocessing
utils/preprocess.py - Cartoon image
- ONNX model test
test_onnx.py
Model training
- Training entry
train.py - UGATIT trainer
models/UGATIT_sadalin_hourglass.py - Image dataset loader
dataset.py - Model weights
models
Model components
- Image generator
models/networks.py - Face ID features
models/face_features.py - MobileFaceNet
models/mobilefacenet.py
Other components
- Portrait user
- Model trainer
Connections 16
- Model trainer → Dataset preparation: prepares data
README.md - Dataset preparation → Face preprocessing: uses pipeline
- Face preprocessing → Face alignment: aligns face
utils/preprocess.py - Face preprocessing → Portrait segmentation: gets mask
utils/preprocess.py - Portrait user → Prediction entry: submits portrait
predict.py - Prediction entry → Inference preprocessing: preprocesses image
predict.py - Prediction entry → Image generator: runs inference
predict.py - Prediction entry → Cartoon image: writes result
predict.py - Portrait user → ONNX model test: runs ONNX test
README.md - Model trainer → Training entry: starts training
README.md - Training entry → UGATIT trainer: builds and trains
train.py - UGATIT trainer → Image dataset loader: loads images
models/UGATIT_sadalin_hourglass.py - UGATIT trainer → Image generator: constructs networks
models/UGATIT_sadalin_hourglass.py - UGATIT trainer → Face ID features: computes face loss
models/UGATIT_sadalin_hourglass.py - Face ID features → MobileFaceNet: extracts features
models/face_features.py - UGATIT trainer → Model weights: saves weights
models/UGATIT_sadalin_hourglass.py