YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

SDXL Fusion Model and Multi-Configuration LoRA for Ship Design

Project Overview

This project addresses the "semantic gap" issue when applying the base SDXL model directly to ship design scenarios, catering to the AI-generated needs of the ship design field. It provides two core assets:

  1. A ship design-specific SDXL model fused via SLERP (combining material optimization and product design capabilities)

  2. Five sets of ship rendering LoRA weights with different rank configurations (adapting to diverse precision and efficiency requirements)

All models have undergone validation in ship design scenarios and can be directly used for industrial design tasks such as ship structure generation, surface material rendering, and detail optimization, balancing generation quality with training/inference efficiency.

1. Core Technical Solutions

1.1 Model Adaptation Strategy for Industrial Design (Ship Design Direction)

1.1.1 Problem Background

The base SDXL model is not optimized for the "professional semantics" of ship design (e.g., hull structure, ship materials, industrial design specifications). Direct application leads to "feature mismatch" (such as shape distortion and material deviation), known as the semantic gap.

1.1.2 Fusion Solution

Domain adaptation is achieved through model fusion, as detailed below:

  • Fusion Objects: Two specifically pre-trained SDXL models

    • Material-Optimized SDXL: Focuses on the precision of ship surface material (e.g., metal, coating) and texture generation

    • Product-Design SDXL: Focuses on the rationality of overall ship structure (e.g., hull contour, cabin layout) and shape design

    • Let the parameters of the two models be $\theta_1$ (material-optimized) and $\theta_2$ (product-design), respectively.

  • Fusion Algorithm: Spherical Linear Interpolation (SLERP)

    Formula:

    $\theta_{\text{fusion}} = \text{SLERP}(\theta_1, \theta_2, \lambda) = \frac{\sin((1-\lambda)\Omega)}{\sin\Omega}\theta_1 + \frac{\sin(\lambda\Omega)}{\sin\Omega}\theta_2$

    Where:

    • $\Omega$: The angle in the parameter space of the two models (measuring the degree of parameter difference)

    • $\lambda$: Fusion coefficient (adjusts the contribution ratio of features from the two models; default $\lambda=0.5$ in this project)

  • Stability Assurance: Perform Singular Value Decomposition (SVD) on the core weight matrices $W_1$ (material-optimized) and $W_2$ (product-design) of the two models. Eigenvalue constraints prevent "weight collapse/explosion" while maintaining the orthogonality of feature representation.

1.2 LoRA Low-Rank Decomposition Technology and Experimental Design

LoRA (Low-Rank Adaptation) is an efficient fine-tuning technology for large models. It reduces the number of parameters by injecting low-rank matrices, adapting to the precise fine-tuning needs of ship design scenarios.

1.2.1 LoRA Principle and Advantages

For the pre-trained weight matrix $W_0 \in \mathbb{R}^{d \times k}$ of the SDXL model ($d$ = input dimension, $k$ = output dimension):

  • Traditional Full-Parameter Fine-Tuning: Requires updating all $d \times k$ parameters, resulting in high costs and low efficiency.

  • LoRA Optimization Scheme: Converts weight updates into the product of low-rank matrices

    Formula: $W_0 + \Delta W = W_0 + A \cdot B^T$

    Where:

    • $W_0$: Frozen pre-trained weights (retains the basic capabilities of the SDXL model)

    • $A$: Down-projection matrix ($\mathbb{R}^{d \times r}$), initialized to a Gaussian distribution $\mathcal{N}(0, \sigma^2)$

    • $B$: Up-projection matrix ($\mathbb{R}^{k \times r}$), initialized to a zero matrix (minimizes initial impact)

    • $r$: LoRA rank parameter (much smaller than $d/k$, reducing the number of trainable parameters by 1-2 orders of magnitude)

1.2.2 Key Parameter Configuration

To ensure training stability, a strategy of fixed ratio between Network_dim (rank ) and Network_alpha (scaling factor ) is adopted:

  • Core Constraint: $\frac{\alpha}{r}$ remains constant (default ratio = 1.0 in this project)

  • Advantage: Avoids parameter scale differences under different rank configurations, eliminating the need to readjust the learning rate.

1.2.3 Controlled Experimental Design

To explore the impact of $r$ on ship rendering quality, five sets of LoRA configurations (all matching fixed $\alpha$) are designed:

Configuration ID LoRA Rank ($r$) Application Scenario Generation Precision Inference Efficiency
LoRA-r8 8 Quick preview, low-resource devices Medium Highest
LoRA-r16 16 Routine design iterations Good High
LoRA-r32 32 Core design scheme generation Excellent Medium
LoRA-r64 64 High-precision detail optimization Extremely High Low
LoRA-r128 128 Final rendering, professional demonstration Top-tier Lowest

ComfyUI_00016_

1.2.4 Weight Update Modulation

The actual weight update of LoRA is modulated by $\alpha$ to ensure consistent initialization scale:

Formula: $\Delta W = \frac{\alpha}{r} \cdot A \cdot B^T$

2. Usage Guide

2.1 Environment Dependencies

  • Python 3.8+

  • PyTorch 2.0+

  • Transformers 4.30+

  • Diffusers 0.20+

  • Safetensors 0.3+

Install dependencies:

pip install torch transformers diffusers safetensors accelerate

2.2 Usage Example for Fused SDXL Model

from diffusers import StableDiffusionXLPipeline

import torch

\# Load the fused model

pipe = StableDiffusionXLPipeline.from\_pretrained(

    "./ship-design-sdxl/fused-sdxl-ship",

    torch\_dtype=torch.float16,

    use\_safetensors=True

).to("cuda")

\# Example of ship design generation (adjust prompts as needed)

prompt = "A large cargo ship, detailed hull structure, anti-corrosion metal coating, industrial design style, high precision, 8k resolution"

negative\_prompt = "distorted, blurry, low quality, non-ship, cartoon style"

image = pipe(

    prompt=prompt,

    negative\_prompt=negative\_prompt,

    width=1024,

    height=768,

    num\_inference\_steps=30,

    guidance\_scale=7.5

).images\[0]

\# Save the generated result

image.save("ship\_design\_result.png")

2.3 Usage Example for Loading LoRA

from diffusers import StableDiffusionXLPipeline

import torch

\# Load the base SDXL (or the fused SDXL from this project)

pipe = StableDiffusionXLPipeline.from\_pretrained(

    "./ship-design-sdxl/fused-sdxl-ship",  # Or path to the official base SDXL model

    torch\_dtype=torch.float16,

    use\_safetensors=True

).to("cuda")

\# Load LoRA (taking r=32 as an example; replace with other configurations)

pipe.load\_lora\_weights("./ship-design-sdxl/lora-ship-r32")

\# Generation (supplement ship-specific terminology in prompts)

prompt = "Offshore patrol ship, streamlined hull, radar system on deck, marine paint texture, photorealistic"

negative\_prompt = "low detail, wrong structure, unrealistic material"

image = pipe(

    prompt=prompt,

    negative\_prompt=negative\_prompt,

    width=1280,

    height=960,

    num\_inference\_steps=40,

    guidance\_scale=8.0

).images\[0]

image.save("ship\_lora\_result.png")

3. Generation Quality Evaluation

3.1 Evaluation Dimensions

The models in this project are validated through the following dimensions (based on reviews by ship design experts):

  1. Structural Accuracy: Rationality of hull proportions and positions of key components (e.g., deck, cabin, propulsion system)

  2. Material Fidelity: Metal reflections, coating textures, and material performance in marine environments

  3. Detail Richness: Clarity and rationality of small components such as railings, pipelines, and equipment

  4. Industrial Design Compliance: Conformity to basic engineering specifications for ship design

3.2 Performance Summary of Each Configuration

  • Fused SDXL: Balanced basic generation capabilities, suitable for initial drafts of various ship designs

  • LoRA-r32/r64: Optimal cost-effectiveness, balancing precision and efficiency; recommended as the primary configuration

  • LoRA-r128: Most detailed, suitable for final design rendering, but requires higher hardware resources

4. Notes

  1. The models are only for industrial design assistance; generated results must be reviewed by professional engineers before use.

  2. LoRA weights must be used with an SDXL model (base version or the fused version from this project) and cannot run independently.

  3. A GPU is recommended for inference (VRAM ≥ 10GB, float16 precision); LoRA-r8/r16 is recommended for low-VRAM devices.

  4. Adding "ship-specific terminology" (e.g., "hull structure", "marine coating") to prompts improves generation quality.

5. Citations and Acknowledgments

  • Base Model: SDXL (Stable Diffusion eXtra Large)

  • Fine-Tuning Technology: LoRA (Low-Rank Adaptation)

  • Fusion Algorithm: SLERP (Spherical Linear Interpolation)

  • Acknowledgments: Thanks to ship design experts for providing scenario validation and feedback.

(注:文档部分内容可能由 AI 生成)

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support