YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
MSEmbGAN: Multi-Stitch Embroidery Synthesis
PyTorch implementation of "MSEmbGAN: Multi-Stitch Embroidery Synthesis via Region-Aware Texture Generation" (IEEE TVCG 2024, PubMed 39167500).
What This Does
Takes a flat design image (e.g., a flower drawing) and synthesizes a photorealistic multi-stitch embroidery rendering with automatic stitch type assignment:
- Satin stitch β narrow regions (needle drops on both sides, snakelike advance)
- Tatami stitch β wide regions (brick-like offset rows, resembling tatami weaving)
- Flat stitch β very small regions (uniform fill without directional variation)
Architecture
Input Content Image (RGB, 256x256)
β
Stitch Classifier β Quick-shift segmentation + morphological erosion
β
Region-Aware Texture Generation Network (WGAN, Lab L channel)
β
Colorization Network (Lab ab channels)
β
Final Colorized Embroidery Image
Files
msembgan/modules.pyβ Custom layers (ReLUConv2d, INSResBlock, MisINSResBlock, etc.)msembgan/networks.pyβ All encoders, generators, discriminators from Supplemental Table 1msembgan/stitch_classifier.pyβ Quick-shift + erosion stitch classification + latent generatormsembgan/model.pyβ Full MSEmbGAN assembly (RTGN + CN)msembgan/losses.pyβ All losses: KL, L1, WGAN, color consistencymsembgan/dataset.pyβ Dataset loaders for aligned/unaligned datamsembgan/train.pyβ 2-step training pipelinemsembgan/inference.pyβ Inference script
Installation
pip install torch torchvision numpy pillow scikit-image scipy tqdm
Training
python -m msembgan.train \
--data_dir ./data \
--epochs 800 --batch_size 2 --lr 0.0002 \
--step1_epochs 200 --step2_epochs 500
Inference
python -m msembgan.inference \
--model ./checkpoints/final.pth \
--input ./image.jpg --output ./embroidery.png
Dataset
Multi-Stitch Embroidery Dataset: https://drive.google.com/drive/folders/1VEg01D0vmO82oAYHr9D7KzDUCRza-DmU (Email fangfei@wtu.edu.cn if unavailable)
Paper
- PDF: https://github.com/CGVSL-NCKU/TVCG_MSEmbGAN/raw/HEAD/MSEmbGAN_paper.pdf
- DOI: 10.1109/TVCG.2024.3447351
License
MIT β clean-room implementation from the paper's architecture tables and equations.
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support