GarmentCode Documentation

repository·main·Indexed 18 days ago

https://github.com/maria-korosteleva/garmentcode

A framework for programming parametric sewing patterns to generate garment designs based on body models. It includes the PyGarment library for designing patterns using base types like Edge, Panel, Component, and Interface, a Configurator GUI, and tools for synthetic data generation and physics simulation using NVIDIA Warp or Qualoth.

Tokens
3.1K
Snippets
11
Records
20
Agent score
62%

What's inside GarmentCode

  1. Overview of GarmentCode

    main

    GarmentCode is a framework for programming parametric sewing patterns. It provides the PyGarment library, which allows developers to design garments using base types like Edge, Panel, Component, and Interface. The project also includes GarmentCodeData, a dataset of 3D made-to-measure garments with sewing patterns.

    Key components include:

    • PyGarment: The core library for designing sewing patterns using edge factories and various operators.
    • Configurator: A GUI/online tool for garment configuration.
    • Data Generation: Tools for running data generation (e.g., using warp).
  2. Change Body Measurements

    main

    To use different body shapes when generating patterns via the command line, modify the body_to_use variable in test_garmentcode.py.

    Available Options:

    • 'neutral' (Default: gender-neutral average body shape)
    • 'mean_female'
    • 'mean_male'
    • 'f_smpl'
    • 'm_smpl'

    Configuration Locations:

    • Measurement Values: Defined in ./assets/body_measurements.
    • Body Shape Examples: Reference files are located in ./assets/bodies.
    • Measurement Descriptions: Detailed descriptions are available in docs/Body Measurements GarmentCode.pdf.
  3. Fit a specific design to multiple body shapes with pattern_fitter.py

    main

    The pattern_fitter.py script allows you to fix specific design parameters while varying only the body shapes. This is useful for studying how a single garment design interacts with different body types.

    Note: The selection of body shapes is NOT randomized. The script traverses the bodies in the specified sample one by one in alphabetical order.

    Default Body Set: The script defaults to the 5000_body_shapes_and_measures sample (this can be changed inside the script).

    # Fit the design from t-shirt.yaml to 100 different body shapes
    python pattern_fitter.py .\assets\design_params\t-shirt.yaml --name t-shirt-fit --size 100
  4. Install dependencies for Maya and Qualoth simulation

    main

    To simulate GarmentCode patterns in Autodesk Maya using Qualoth, you must install Maya, Qualoth, and the pygarment package into the Maya Python environment. Note that installing warp is not required because the Maya UI uses Qualoth simulation instead of the warp simulator.

    To install pygarment, use the mayapy executable to run pip within your Maya environment.

    mayapy -m pip install pygarment
  5. Prepare for GarmentCodeData generation

    main

    Before running the synthetic data generation pipeline, complete the following steps:

    1. Obtain body shapes: Download a dataset of sample body shapes from GarmentCodeData or create your own using GarmentMeasurements.
    2. Configure paths: Set up the system.json file as described in the Installation guide.
    3. Customize design parameters: Edit assets/design_params/default.yaml to adjust parameter ranges and probabilities.
      • Example: To restrict generation to upper garments only, set design['meta']['bottom']['v'] to null and design['meta']['bottom']['default_prob'] to 1.0.
    4. Configure simulation: Prepare a simulation configuration file specifying material properties, geometry resolution, and rendering hyperparameters.
  6. Run GarmentViewer in Autodesk Maya

    main

    GarmentViewer is a GUI script for Maya that allows you to load and simulate sewing patterns from JSON files.

    To launch the GUI:

    1. Open Autodesk Maya.
    2. Copy the contents of ./gui/maya_garmentviewer.py.
    3. Paste the contents into the Maya Python scripting console and execute it.
    # Copy contents of ./gui/maya_garmentviewer.py into Maya Python console
  7. Run GarmentCode via Command Line

    main

    You can generate sewing patterns from design and body parameters using the command line script. By default, running the script will generate a pattern based on the current state of assets/design_params/t-shirt.yaml for a neutral body and save the output to the logs folder.

    To customize the output, you must modify the parameters directly within the test_garmentcode.py script.

    python test_garmentcode.py
  8. Manual Installation via Conda

    main

    If you need to install the library manually or in editable mode, follow these steps. This process ensures all dependencies from setup.cfg are met and allows for the manual integration of the Warp simulator.

    1. Create and activate a Python 3.9 environment.
    2. Install the package in editable mode.
    3. Build and install the specific Warp version for GarmentCode.
    4. Add the root repository to your PYTHONPATH.
    conda create -n garmentcode python=3.9
    conda activate garmentcode
    pip install -e .
    # <build and install warp for GarmentCode>
  9. Simulate patterns with pattern_data_sim.py

    main

    The pattern_data_sim.py script performs physics simulation (draping) for each pattern in a provided dataset.

    Key Arguments:

    • --data: The name of the sewing patterns dataset (located in system['datasets_path']).
    • --config: Path to the simulation configuration file.
    • --default_body: When used, simulates the designs fitted to the neutral body. When omitted, simulates designs fitted to random body shapes.
    • --minibatch <int>: Specifies the number of samples to simulate before exiting. This is useful for running large simulations on remote servers in manageable chunks.
    # Simulate designs fitted to the neutral body
    python ./pattern_data_sim.py --data garmentcodedata --config /path/to/sim_config --default_body
    
    # Simulate designs fitted to random body shapes
    python ./pattern_data_sim.py --data garmentcodedata --config /path/to/sim_config
    
    # Run simulation in a small batch of 100 samples
    python ./pattern_data_sim.py --data garmentcodedata --config /path/to/sim_config --minibatch 100
  10. Modify Garment Style Parameters

    main

    To generate different garment samples, modify the style parameters in the configuration files (e.g., assets/design_params/t-shirt.yaml).

    Workflow:

    1. Update parameter values (the 'v:' field under a parameter name) within their valid ranges.
    2. Run python test_garmentcode.py.
    3. Find the resulting sewing patterns in system['output']/t-shirt_<timestamp>/.

    Note on Units: Parameter values are expressed in centimeters (cm) for distances, degrees for angles, or as fractions.

  11. Sample sewing patterns with pattern_sampler.py

    main

    The pattern_sampler.py script generates 2D pattern samples from GarmentCode parametric garment programs and a body shape dataset. It produces design samples fitted to both a neutral body shape and a random shape sample.

    Default Behavior:

    • Uses the 5000_body_shapes_and_measures folder in system['bodies_default_path'] for body samples.
    • Uses assets/design_params/default.yaml for design parameter sets, ranges, and probabilities.

    To use different body sets or design parameter files, you must update the script directly.

    # Generate a dataset of 100 samples
    python pattern_sampler.py --name garmentcodedata --size 100
    
    # Generate a dataset with a batch ID for parallel processing
    python pattern_sampler.py --name garmentcodedata --size 100 --batch_id 0