🚀 StableMaterials
StableMaterials 是一个基于扩散模型的工具,专为生成逼真的基于物理的渲染(PBR)材质而设计。该模型将半监督学习与潜在扩散模型(LDMs)相结合,能够根据文本或图像提示生成高分辨率、可平铺的材质贴图。StableMaterials 可以推断漫反射(基础颜色)和镜面反射(粗糙度、金属度)属性,以及材质的微观结构(高度、法线)。🌟
如需了解更多详情,请访问项目页面,或在 arXiv 上阅读完整论文。
⚠️ 重要提示
此仓库包含 LDM 和 LCM 版本的基础模型的权重和管道代码。精炼模型及其管道和修复管道将很快发布。
🚀 快速开始
你可以根据提供的代码示例,使用 StableMaterials 模型生成材质。具体代码在“🧑💻 使用示例”章节中有详细展示。
✨ 主要特性
- 半监督学习:模型使用带注释和未带注释的数据进行训练,利用对抗训练从大规模预训练图像生成模型中提炼知识。 📚
- 知识蒸馏:将使用 SDXL 模型生成的未注释纹理样本纳入训练过程,弥合不同数据分布之间的差距。 🌐
- 潜在一致性:采用潜在一致性模型促进快速生成,减少生成高质量输出所需的推理步骤。 ⚡
- 特征滚动:在 U-Net 架构的每个卷积和注意力层引入特征滚动技术,实现可平铺性。 🎢
📦 安装指南
文档未提及安装相关内容,故跳过此章节。
💻 使用示例
基础用法
标准模型
from diffusers import DiffusionPipeline
from diffusers.utils import load_image
pipe = DiffusionPipeline.from_pretrained(
"gvecchio/StableMaterials",
trust_remote_code=True,
torch_dtype=torch.float16
)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
pipe = pipe.to(device)
material = pipe(
prompt="Old rusty metal bars with peeling paint",
guidance_scale=10.0,
tileable=True,
num_images_per_prompt=1,
num_inference_steps=50,
).images[0]
material = pipe(
prompt=load_image("path/to/input_image.jpg"),
guidance_scale=10.0,
tileable=True,
num_images_per_prompt=1,
num_inference_steps=50,
).images[0]
basecolor = material.basecolor
normal = material.normal
height = material.height
roughness = material.roughness
metallic = material.metallic
一致性模型
from diffusers import DiffusionPipeline, LCMScheduler, UNet2DConditionModel
from diffusers.utils import load_image
unet = UNet2DConditionModel.from_pretrained(
"gvecchio/StableMaterials",
subfolder="unet_lcm",
torch_dtype=torch.float16,
)
pipe = DiffusionPipeline.from_pretrained(
"gvecchio/StableMaterials",
trust_remote_code=True,
unet=unet,
torch_dtype=torch.float16
)
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
pipe = pipe.to(device)
material = pipe(
prompt="Old rusty metal bars with peeling paint",
guidance_scale=10.0,
tileable=True,
num_images_per_prompt=1,
num_inference_steps=4,
).images[0]
material = pipe(
prompt=load_image("path/to/input_image.jpg"),
guidance_scale=10.0,
tileable=True,
num_images_per_prompt=1,
num_inference_steps=4,
).images[0]
basecolor = material.basecolor
normal = material.normal
height = material.height
roughness = material.roughness
metallic = material.metallic
📚 详细文档
模型架构
🧩 基础模型
基础模型使用压缩变分自编码器(VAE)生成低分辨率(512x512)的材质贴图,然后进行潜在扩散过程。该架构基于 LDM 范式的 MatFuse 改编,针对材质贴图生成进行了优化,注重多样性和高视觉保真度。 🖼️
🔑 关键特性
- 半监督学习:模型使用带注释和未带注释的数据进行训练,利用对抗训练从大规模预训练图像生成模型中提炼知识。 📚
- 知识蒸馏:将使用 SDXL 模型生成的未注释纹理样本纳入训练过程,弥合不同数据分布之间的差距。 🌐
- 潜在一致性:采用潜在一致性模型促进快速生成,减少生成高质量输出所需的推理步骤。 ⚡
- 特征滚动:在 U-Net 架构的每个卷积和注意力层引入特征滚动技术,实现可平铺性。 🎢
🗂️ 训练数据
该模型在 MatSynth 和 Deschaintre 等人的组合数据集上进行训练,包括 6198 种独特的 PBR 材质。它还包含使用各种提示从 SDXL 模型生成的 4000 个纹理 - 文本对。 🔍
🔧 局限性
虽然 StableMaterials 表现出强大的性能,但它也有一些局限性:
- 对于描述复杂空间关系的复杂提示,它可能会遇到困难。 🧩
- 它可能无法准确表示高度详细的图案或图形。 🎨
- 它偶尔会为某些材质类型生成不正确的反射属性。 ✨
未来的更新旨在通过纳入更多样化的训练提示和改进模型对复杂纹理的处理来解决这些局限性。
🔧 技术细节
文档未提供更详细的技术细节内容,故跳过此章节。
📄 许可证
本项目采用 OpenRAIL 许可证。
📖 引用
如果你在研究中使用了此模型,请引用以下论文:
@article{vecchio2024stablematerials,
title={StableMaterials: Enhancing Diversity in Material Generation via Semi-Supervised Learning},
author={Vecchio, Giuseppe},
journal={arXiv preprint arXiv:2406.09293},
year={2024}
}