---
title: cv_diffuser_text-texture-generation
canonical_url: "https://www.modelscope.cn/models/iic/cv_diffuser_text-texture-generation"
md_url: "https://www.modelscope.cn/models/iic/cv_diffuser_text-texture-generation.md"
repository: iic/cv_diffuser_text-texture-generation
chinese_name: "文本引导模型纹理生成-三维视觉"
last_updated: 2023-09-21
license: "Apache License 2.0"
model_type:
  - CNN
parameters: 1.3B
tensor_type:
  - I64
  - F32
library_name:
  - safetensors
  - diffusers
  - pytorch
frameworks:
  - pytorch
domain:
  - cv
downloads: 189
stars: 6
tags:
  - 3D
  - reconstruction
  - "生成"
  - "三维视觉"
  - "编辑"
  - "重建"
---

# cv_diffuser_text-texture-generation

> cv_diffuser_text-texture-generation - iic 在 ModelScope 开源的模型。输入一个obj格式的3d模型，输入一段描述模型纹理的文字，在输入的3d模型上生成对应描述的纹理

iic/cv_diffuser_text-texture-generation 是 ModelScope 魔搭社区上的 1.3B 参数机器学习模型，采用 Apache License 2.0 许可。

- **Repository**: iic/cv_diffuser_text-texture-generation
- **License**: Apache License 2.0
- **Parameters**: 1.3B
- **Tags**: 3D, reconstruction, 生成, 三维视觉, 编辑, 重建
- **Downloads**: 189
- **Stars**: 6
- **Last updated**: 2023-09-21

Source: https://www.modelscope.cn/models/iic/cv_diffuser_text-texture-generation

---

文本引导纹理生成是通过输入一个3D白模和描述其纹理的语句，生成符合该3D模型和描述的纹理，该方法使用了stable diffusion预训练模型，实际使用可替换为其他基模。

白模生成纹理渲染效果展示：

<div align=center>
<img src="img/mesh1.png" height="300px">  <img src="img/mesh1.gif" height="300px">
</div>

<div align=center>
<img src="img/mesh2.png" height="300px">  <img src="img/mesh2.gif" height="300px">
</div>

### 模型描述
该方法使用文生图大模型为预训练模型，使用3D模型的深度or法向图作为controlnet引导条件，使得文生图模型可以生成对应3D模型的图像，之后使用pytorch3d反向映射回原图，中间使用文生图-inpaint模型做中间纹理填充，使最终呈现效果具有一致性。

### 如何使用

（注意：该方法目前仅支持GPU推理，且需要pytorch3d>=0.7.0版本，diffusers>=0.17.0版本，同时安装torch对应版本的xformers库）

在ModelScope框架上，提供输入obj格式mesh的路径和描述prompt，即可以通过简单的Pipeline调用来生成对应纹理。

#### 代码范例
```python
from modelscope.outputs import OutputKeys
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

video_inpainting = pipeline(Tasks.text_texture_generation, 
                       model='damo/cv_diffuser_text-texture-generation')
result_status = video_inpainting({'mesh_path':'data/test/mesh/mesh1.obj',
                           'prompt':'old backpage'})
print(result_status)

```
- mesh\_path 为输入mesh的路径
- prompt 为对纹理的描述

正常情况下，在原路径下会生成mesh_post.obj文件及其对应纹理


### 模型局限性以及可能的偏差
受限于预训练模型，生成纹理对于一些case可能不适用或产生一些偏差，请用户自行评测后决定如何使用。
