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

Abstract

Digitally reproducing the appearance of fabrics like wool or cotton is a significant challenge in computer graphics due to the intricate fiber-level details required for realism. This paper introduces a neural inverse procedural modeling framework that reconstructs high-fidelity, fiber-level 3D yarn models from a single photograph. By utilizing an ensemble of neural networks and a novel latent-space regularization technique, the framework bridges the "sim-to-real" gap, allowing models trained entirely on synthetic data to accurately infer the complex physical parameters of real-world knitting yarns.

Introduction

To look "real," a digital fabric model must account for minute details: how fibers twist into "plies," how those plies bundle into yarn, and the "fuzziness" caused by flyaways (stray fibers). Existing methods typically fall into two extremes: they are either too simplified, treating yarn as smooth cylinders, or too expensive, requiring micro-CT scans to capture internal structures. This research tackles the challenge of Inverse Procedural Modeling: taking a single 2D image and automatically estimating the underlying 3D procedural parameters—such as twist pitch, fiber count, and hairiness—needed to recreate that specific yarn.

Hierarchical Procedural Generation

The foundation of this approach is a sophisticated procedural generator that mimics the physical manufacturing process. The model follows a hierarchy where fibers are bundled into plies, and plies are subsequently twisted into yarn. Unlike previous models, this generator includes elliptical fiber cross-sections, which significantly improve the accuracy of specular highlights and overall shading, making the resulting yarn look much more like natural wool.

The hierarchical yarn generation process: a) coordinate frames, b-c) ply construction with elliptical cross-sections, d-e) twisting plies into the final yarn structure.

Modeling Flyaways and Migration

A key contribution to the visual fidelity is the realistic "flyaway" model. The researchers distinguish between two types of stray fibers: "loop flyaways," where both ends are tucked into the yarn core, and "hair flyaways," where one end remains loose. This distinction, combined with fiber migration (jitter in the radial and longitudinal directions), allows the model to capture the characteristic fuzziness of different yarn types like cotton or acrylic.

Visualization of different flyaway types and fiber migration paths used to simulate yarn fuzziness.

Neural Inference and Domain Adaptation

The inference process uses a multi-stage approach combining computer graphics and deep learning:

  1. Network Ensembles: Saliency map analysis revealed that a single network struggles to learn all parameters simultaneously. The network naturally focuses on the yarn center for twisting parameters and the borders for flyaway statistics. Consequently, the authors use an ensemble of networks specialized for different parameter types.
  2. Sim-to-Real via Latent Alignment: To make a model trained on synthetic images work on real photos, a semi-supervised training loop was implemented. This includes a novel latent regularization term that penalizes the distance between the latent codes of synthetic images and the average latent code of real images. This forces the network to find a shared representation, making it robust to real-world photographic artifacts like noise and lighting variations.

Results and Utility

The method demonstrates impressive performance, with inferred parameters producing renderings nearly indistinguishable from original photographs. The ensemble approach significantly reduces validation loss compared to single-regressor models. Beyond reconstruction, these inferred parameters enable downstream utility: users can "edit" yarns—for example, by reducing hairiness or increasing twist density—and virtually knit them into realistic fabric patches.

Limitations and Future Work

Currently, the generator assumes a standard helix-like twisting and may struggle with unusual, non-helical fiber arrangements. While the generator supports deep hierarchies, inference was primarily tested up to three levels. Future work aims to integrate the inference of reflectance properties, such as color and translucency, to provide a 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