Project Icon

SceneTex

基于扩散先验的室内场景高质量纹理合成方法

SceneTex是一种基于扩散先验的室内场景纹理合成方法。该方法将纹理合成视为RGB空间中的优化问题,采用多分辨率纹理场隐式编码网格外观,并使用交叉注意力解码器确保跨视图风格一致性。SceneTex能为3D-FRONT场景生成高质量、风格一致的纹理,在视觉质量和提示保真度方面优于现有方法。

SceneTex: High-Quality Texture Synthesis for Indoor Scenes via Diffusion Priors

Introduction

We propose SceneTex, a novel method for effectively generating high-quality and style-consistent textures for indoor scenes using depth-to-image diffusion priors. Unlike previous methods that either iteratively warp 2D views onto a mesh surface or distillate diffusion latent features without accurate geometric and style cues, SceneTex formulates the texture synthesis task as an optimization problem in the RGB space where style and geometry consistency are properly reflected. At its core, SceneTex proposes a multiresolution texture field to implicitly encode the mesh appearance. We optimize the target texture via a score-distillation-based objective function in respective RGB renderings. To further secure the style consistency across views, we introduce a cross-attention decoder to predict the RGB values by cross-attending to the pre-sampled reference locations in each instance. SceneTex enables various and accurate texture synthesis for 3D-FRONT scenes, demonstrating significant improvements in visual quality and prompt fidelity over the prior texture generation methods.

Please also check out the project website here.

For additional detail, please see the SceneTex paper:
"SceneTex: High-Quality Texture Synthesis for Indoor Scenes via Diffusion Priors"
by Dave Zhenyu Chen, Haoxuan Li, Hsin-Ying Lee, Sergey Tulyakov, and Matthias Nießner
from Technical University of Munich and Snap Research.

Setup

The code is tested on Ubuntu 20.04 LTS with PyTorch 2.0.1 CUDA 11.7 installed. Please follow the following steps to install PyTorch first. To run our method, you should at least have a NVIDIA GPU with 48 GB RAM (NVIDIA RTX A6000 works for us).

# create and activate the conda environment
conda create -n scenetex python=3.9
conda activate scenetex

# install PyTorch 2.0.1
conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.7 -c pytorch -c nvidia

Then, install PyTorch3D:

# install runtime dependencies for PyTorch3D
conda install -c fvcore -c iopath -c conda-forge fvcore iopath
conda install -c bottler nvidiacub

# install PyTorch3D
conda install pytorch3d -c pytorch3d

Install xformers to accelerate transformers:

conda install xformers -c xformers

Install tinycudann:

pip install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch

Install the necessary packages listed out in requirements.txt:

pip install -r requirements.txt

3D-FRONT scenes

Please download the 3D-FRONT scenes, and unzip it under data/. You should be able to see the preprocessed data constructed as follows:

data/
    |-- 3D-FRONT_preprocessed/
        |-- scenes/
            |-- <scene_id>
                |-- <room_id>
                    |-- meshes/
                    |-- cameras/

Usage

To make sure everything is set up and configured correctly, you can run the following script to generate texture for a 3D-FRONT scene.

./bash/bohemian.sh

All generated assets should be found under outputs. To configure the style or the target scene, you can run the following script:

stamp=$(date "+%Y-%m-%d_%H-%M-%S")
log_dir="outputs/" # your output dir
prompt="a bohemian style living room" # your prompt
scene_id="93f59740-4b65-4e8b-8a0f-6420b339469d/room_4" # preprocessed scene

python python scripts/train_texture.py --config config/template.yaml --stamp $stamp --log_dir $log_dir --prompt "$prompt" --scene_id "$scene_id"

We provide a template file for all critical parameters in config/template.yaml. Please take a look at it in case you want to further costumize the optimization process.

:star2: Try on your own scenes :star2:

Our method is of course not limited to 3D-FRONT synthetic scenes. It can also be applied to your own synthetic scenes, and even to real indoor scenes such as ScanNet or to outdoor scenes. We provide some cool results beyond 3D-FRONT scenes:

  1. Real Indoor Scene from ScanNet:

  1. Ourdoor Scene:

Here, we provide a thorough guideline for setting up the input data structure. On a high level, your data should be constructed under data/ like this:

data/
    |-- <your-data-dir>/               # this is the root directory for your meshes
        |-- <name-of-your-scene>/      # name your scene as you like, e.g. living_room/
            |-- cameras/               # root dir of all pre-sampled cameras
                |-- sphere.yaml        # (if applicable) spherical cameras pointing at the scene center
                |-- blender.json       # (if applicable) interpolated cameras in the scene via Blender
                |-- blenderproc.json   # (if applicable) sampled cameras in the scene via BlenderProc
            |-- meshes/                # root dir of all your mesh data
                |-- stuff/             # dir of structural meshes, e.g. wall, floor, ceiling, etc.
                    |-- 0_wall.obj
                    |-- 0_wall.mtl     # note .mtl is not necessary - we only support .obj with single material
                    |-- ...
                    |-- (or simply use a composed 0_room.obj for the whole scene structure)
                |-- things/            # dir of object meshes, e.g. table, chair, lamp, etc.
                    |-- 1_table.obj
                    |-- 1_table.mtl
                    |-- ...
                |-- scene_config.json  # configuration file, see details below
                |-- scene.obj          # (if applicable) a composed .obj file for the whole scene, 
                |-- scene.mtl          # (if applicable) a scene material, note only a single material is supported
                |-- (provide scene.obj and scene.mtl if the instance segmentations are not available)

Cameras

We provide three types of the pre-sampled cameras: spherical cameras, Blender cameras, and BlenderProc. We recommend the spherical cameras as the default cameras for its wider coverage of the scene surface. The other two can be additionally applied when needed. We assume Y is up and -Z is forward.

  1. Spherical Cameras

The camera parameters should be defined in sphere.yaml as the following example:

# sphere camera space
dist:                     # distance to the sphere center
  min: 0.5                # min and max are usually set to the same value
  max: 0.5
  num_linspace: 1         # sphere diameter is recommended to remain unchanged

elev:                     # elevations from XZ-plane
  min: -30
  max: 30
  num_linspace: 10        # number of evevations between min and max

azim:                     # azimuths to -Z
  min: -180
  max: 180
  num_linspace: 100       # number of azimuths between min and max

fov:                      # field-of-views
  min: 45
  max: 75
  num_linspace: 5         # number of field-of-view between min and max

at: [[3.0, 0.75, -0.4]]   # sphere center (not necessarily the scene center)

Please note all parameters should be defined according to your own data. It's recommended to check the measure info of scene mesh in MeshLab first.

  1. Blender Cameras

Interpolate cameras from selected Blender keyframes are much straightforward in terms of visualization. Please refer to online tutorials of Blender keyframes for more info. We provide a python script for saving the interpolated Blender cameras in tools/save_blender_cameras.py. To apply it, please copy and paste this script in Blender (new script in Scripting).

The Blender cameras should be saved under cameras/ and renamed to blender.json.

  1. BlenderProc Cameras

To avoid all manual efforts, we also support automatically sampled cameras from BlenderProc scripts. All cameras are randomly sampled in the scene based on a pre-defined sampling rule, such as heights from the ground, number of visible instances, etc.. Please refer to this tutorial for more info. Note that you might have to flip/rotate your mesh first.

The Blender cameras should be saved under cameras/ and renamed to blenderproc.json.

Meshes

All mesh data should be constructed as described above. Structural .obj files can be composed to a single 0_room.obj for simplicity. If you don't have the segmented objects for the scene, you can also put a single scene.obj there. Please note we only support a single material for each input .obj file. We only support triangular meshes.

No matter how you construct the input mesh data, it's critical to define all meshes in the scene_config.json file. Here, we provide an example for it:

{
    "0": {
        "name": "room",                                                # name of the object
        "type": "stuff",                                               # type of the object
        "path": "data/examples/living_room/meshes/stuff/0_room.obj",   # path to the object
        "prompt": "a living room"                                      # description of the object
    },
    "1": {
        "name": "table",
        "type": "things",
        "path": "data/examples/living_room/meshes/things/1_table.obj",
        "prompt": "a table"
    },
    "2": {
        "name": "lamp",
        "type": "things",
        "path": "data/examples/living_room/meshes/things/2_lamp.obj",
        "prompt": "a lamp"
    }
}

If you only have a mesh without segmentations for the whole scene, you can simply define the scene as:

{
    "0": {
        "name": "room",
        "type": "stuff",
        "path": "data/examples/meshes/scene.obj",   # everything is composed to this single .obj file
        "prompt": "a room"
    }
}

This is quite flexible especially when you want to texture a reconstructed scene such as ScanNet.

Run it!

After the input mesh data is set up, you should adjust all critical parameters in config/template.yaml. Most importantly, you should define which cameras you want to use, and all path info at the end of the YAML file.

Then, you can wrap up everything by putting the following lines into a shell script:

stamp=$(date "+%Y-%m-%d_%H-%M-%S")
log_dir=""        # TODO input your output dir
prompt=""         # TODO input your prompt
scene_id=""       # TODO input <name-of-your-scene>

python python scripts/train_texture.py --config config/template.yaml --stamp $stamp --log_dir $log_dir --prompt "$prompt" --scene_id "$scene_id"

Now everything is in place. Let's run it!

Citation

If you found our work helpful, please kindly cite this papers:

@misc{chen2023scenetex,
      title={SceneTex: High-Quality Texture Synthesis for Indoor Scenes via Diffusion Priors}, 
      author={Dave Zhenyu Chen and Haoxuan Li and Hsin-Ying Lee and Sergey Tulyakov and Matthias Nießner},
      year={2023},
      eprint={2311.17261},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

Acknowledgement

We would like to thank yuanzhi-zhu/prolific_dreamer2d for providing such a great and powerful codebase for variational score distillation.

License

SceneTex is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Copyright (c) 2023 Dave Zhenyu Chen, Haoxuan Li, Hsin-Ying Lee, Sergey Tulyakov, and Matthias

项目侧边栏1项目侧边栏2
推荐项目
Project Cover

豆包MarsCode

豆包 MarsCode 是一款革命性的编程助手,通过AI技术提供代码补全、单测生成、代码解释和智能问答等功能,支持100+编程语言,与主流编辑器无缝集成,显著提升开发效率和代码质量。

Project Cover

AI写歌

Suno AI是一个革命性的AI音乐创作平台,能在短短30秒内帮助用户创作出一首完整的歌曲。无论是寻找创作灵感还是需要快速制作音乐,Suno AI都是音乐爱好者和专业人士的理想选择。

Project Cover

白日梦AI

白日梦AI提供专注于AI视频生成的多样化功能,包括文生视频、动态画面和形象生成等,帮助用户快速上手,创造专业级内容。

Project Cover

有言AI

有言平台提供一站式AIGC视频创作解决方案,通过智能技术简化视频制作流程。无论是企业宣传还是个人分享,有言都能帮助用户快速、轻松地制作出专业级别的视频内容。

Project Cover

Kimi

Kimi AI助手提供多语言对话支持,能够阅读和理解用户上传的文件内容,解析网页信息,并结合搜索结果为用户提供详尽的答案。无论是日常咨询还是专业问题,Kimi都能以友好、专业的方式提供帮助。

Project Cover

讯飞绘镜

讯飞绘镜是一个支持从创意到完整视频创作的智能平台,用户可以快速生成视频素材并创作独特的音乐视频和故事。平台提供多样化的主题和精选作品,帮助用户探索创意灵感。

Project Cover

讯飞文书

讯飞文书依托讯飞星火大模型,为文书写作者提供从素材筹备到稿件撰写及审稿的全程支持。通过录音智记和以稿写稿等功能,满足事务性工作的高频需求,帮助撰稿人节省精力,提高效率,优化工作与生活。

Project Cover

阿里绘蛙

绘蛙是阿里巴巴集团推出的革命性AI电商营销平台。利用尖端人工智能技术,为商家提供一键生成商品图和营销文案的服务,显著提升内容创作效率和营销效果。适用于淘宝、天猫等电商平台,让商品第一时间被种草。

Project Cover

AIWritePaper论文写作

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

投诉举报邮箱: service@vectorlightyear.com
@2024 懂AI·鲁ICP备2024100362号-6·鲁公网安备37021002001498号