Coder Social home page Coder Social logo

jittor-jonelab-landscape_synthesis's Introduction

基于扩散模型的Jittor草图生成风景

注:第一行是原图,第二行是语义分割图,第三行是我们的模型根据语义图生成的结果。

简介

本项目包含了第二届计图挑战赛计图 - 语义图生成风景比赛的代码实现。我们采用隐空间扩散模型生成风景图,模型分为两阶段:一阶段训练autoencoder,压缩和重建风景图;二阶段训练扩散模型,随机生成噪声,和语义图拼接在一起,映射到一阶段隐空间中进行扩散,最后使用一阶段的decoder对扩散结果进行解码生成风景图。

成绩

  • A榜:10/154
  • B榜:12/31
  • B榜+大众投票:10/31

安装

本项目可在 2 张 rtx titan 上运行。

运行环境

  • ubuntu 20.04 LTS
  • python >= 3.7
  • jittor >= 1.3.0

安装依赖

执行以下命令安装 python 依赖

pip install -r requirements.txt

预训练模型

下载预训练模型 download link,放到ckpts/下。

数据准备

DATA_DIR/
|-- train_val/
|   |-- 1.jpg
|   |
|   |-- train.txt
|   |-- val.txt
|
|-- test/
|   |-- 1.jpg
|   |
|   |-- test.txt
|
|-- test_B/
|   |-- 1.jpg
|   |
|   |-- test_B.txt

在configs文件夹下的配置文件中修改数据集路径。

训练

模型分为两阶段:vqgan和ldm,分开训练

  • 单卡训练可运行以下命令:
python train_vqgan.py

python train_ldm.py 
  • 多卡训练可以运行以下命令:
mpirun --allow-run-as-root -np 2 python train_vqgan.py

mpirun --allow-run-as-root -np 2 python train_ldm.py 

推理

生成测试集上的结果可以运行以下命令:

python inference_jittor.py

致谢

此项目基于论文 High-Resolution Image Synthesis with Latent Diffusion Models 实现,代码参考 latent-diffusion

jittor-jonelab-landscape_synthesis's People

Contributors

js2hou avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.