Neural inverse procedural modeling of knitting yarns from images

Elena Trunz, Jonathan Klein, Jan U. Müller, Lukas Bode, Ralf Sarlette, Michael Weinmann, Reinhard Klein · DOI

TL;DR

This paper introduces a neural inverse procedural modeling framework that can reconstruct high-fidelity, fiber-level 3D yarn models from a single photograph. By using an ensemble of neural networks and a novel latent-space regularization technique, the researchers successfully bridge the "sim-to-real" gap, allowing models trained entirely on synthetic data to accurately infer the complex physical parameters of real-world knitting yarns.

What Problem Does This Paper Address?

Digitally reproducing the appearance of fabrics like wool or cotton is notoriously difficult. To look "real," a model needs to account for fiber-level details: how fibers twist into "plies," how those plies bundle into yarn, and the "fuzziness" caused by flyaways (stray fibers).

Existing methods usually fall into two camps: they are either too simplified (treating yarn as smooth cylinders) or too expensive (requiring micro-CT scans to capture internal structures). The authors tackle the challenge of Inverse Procedural Modeling: taking a single, simple 2D image and automatically "guessing" the underlying 3D procedural parameters (like twist pitch, fiber count, and hairiness) needed to recreate that specific yarn.

Methods

The authors propose a multi-stage approach combining computer graphics and deep learning:

  1. A Sophisticated Procedural Generator: They built a hierarchical yarn generator that mimics the manufacturing process (fibers $\rightarrow$ plies $\rightarrow$ yarn). Unlike previous models, this one includes elliptical fiber cross-sections and a more realistic "flyaway" model that distinguishes between "loop flyaways" (both ends tucked in) and "hair flyaways" (one end loose).
  2. Network Ensembles: Through saliency map analysis, the team discovered that a single network struggles to learn all parameters at once. Instead, they use an ensemble of networks. Some focus on the "raw" yarn geometry (the core structure), while others specialize in flyaway statistics.
  3. Domain Adaptation: To make a model trained on synthetic images work on real photos, they implemented a semi-supervised training loop. This includes a standard reconstruction loss (autoencoder) and a novel latent regularization term. This term explicitly penalizes the distance between the latent codes of synthetic images and the average latent code of real images, forcing the network to find a shared representation for both.

Datasets

Because no annotated yarn dataset existed, the authors created their own:

  • Synthetic Dataset: 4,000 training images and 345 validation images generated with their procedural tool, complete with ground-truth parameter labels.
  • Real-World Test Set: A collection of high-resolution photographs of various knitting yarns (wool, acrylic, cotton, etc.) captured under controlled lab conditions using a Sony $\alpha$7RIII.

The authors have committed to releasing both the dataset and the yarn generator to the research community.

Key Insights and Ideas

  • Spatial Specialization: Saliency maps revealed that the network looks at the center of the yarn to determine twisting parameters but shifts its focus to the "border" regions to estimate flyaway characteristics. This justified the move to an ensemble architecture.
  • Sim-to-Real via Latent Alignment: Simply training on synthetic data isn't enough because real photos have different noise and lighting. By forcing the synthetic latent codes to cluster around the "average" real-world latent code, the model becomes much more robust to real-world photographic artifacts.
  • Geometry Affects Shading: A subtle but vital insight was that using elliptical (rather than circular) fiber cross-sections significantly changes how specular highlights appear. Even if you can't "see" the ellipse, the resulting shading makes the yarn look much more like natural wool.

Key Results

The method demonstrates impressive qualitative and quantitative performance:

  • Accuracy: The ensemble approach significantly reduced validation loss compared to a single "all-in-one" regressor, particularly for sensitive parameters like twist pitch ($\alpha$).
  • Visual Fidelity: Renderings produced using the inferred parameters from real photos (e.g., a pink wool yarn) are nearly indistinguishable from the original photographs in terms of structure and fuzziness.
  • Robustness: The model remains stable across different exposure times, provided the images aren't extremely over- or under-exposed.
  • Downstream Utility: The authors showed that the inferred parameters can be used to "edit" yarns (e.g., making a yarn less hairy or more tightly twisted) and then virtually knit them into full fabric patches that look realistic.

Limitations and Future Work

While powerful, the current model has a few constraints:

  • Twist Variety: The generator currently assumes a standard "helix-like" twisting. It struggles with unusual, non-helical fiber arrangements sometimes found in specialty yarns.
  • Hierarchy Depth: While the generator supports infinite levels of hierarchy (yarns made of yarns), the current neural inference was only tested up to three levels.
  • Reflectance: The current work focuses on geometry and structure. The authors suggest that future work should integrate the inference of reflectance properties (color, shininess, and translucency) to provide a truly complete "image-to-digital-twin" solution.

Summary updated

BibTeX
@article{trunz2024neural,
  author = {Elena Trunz and Jonathan Klein and Jan U. Müller and Lukas Bode and Ralf Sarlette and Michael Weinmann and Reinhard Klein},
  title = {{Neural inverse procedural modeling of knitting yarns from images}},
  journal = {Comput. Graph.},
  year = {2024},
  doi = {10.1016/j.cag.2023.12.013},
}
Figure