Skip to content

Commit

Permalink
[ADD] inference code
Browse files Browse the repository at this point in the history
  • Loading branch information
markkua committed Dec 4, 2023
1 parent 23f8b0e commit dfc0e2f
Show file tree
Hide file tree
Showing 20 changed files with 1,550 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

# ignore these folders
checkpoint/
data/
output/
temp/
wandb/
venv/

**/.ipynb_checkpoints/
.vscode/

# ignore these types
*.pyc
*.out
*.log
*.mexa64
*.pdf
*.tar
437 changes: 437 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

107 changes: 106 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,108 @@
# Marigold: Repurposing Diffusion-Based Image Generators for Monocular Depth Estimation

## Code coming soon
This repository represents the official implementation of the paper titled "Repurposing Diffusion-Based Image Generators for Monocular Depth Estimation".

[![Website](doc/badges/badge-website.svg)](https://marigoldmonodepth.github.io)
[![Paper](doc/badges/badge-pdf.svg)]()
[![License](doc/badges/badge-license.svg)](LICENSE)
<!-- [![GitHub](https://img.shields.io/github/stars/prs-eth/Marigold?style=default&label=GitHub%20★&logo=github)](https://github.com/prs-eth/Marigold) -->
<!-- [![HF Space](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Space-blue)]() -->
<!-- [![Open In Colab](doc/badges/badge-colab.svg)]() -->
<!-- [![Docker](doc/badges/badge-docker.svg)]() -->
<!-- ### [Repurposing Diffusion-Based Image Generators for Monocular Depth Estimation]() -->

[Bingxin Ke](http://www.kebingxin.com/),
[Anton Obukhov](https://www.obukhov.ai/),
[Shengyu Huang](https://shengyuh.github.io/),
[Nando Metzger](https://nandometzger.github.io/),
[Rodrigo Caye Daudt](https://rcdaudt.github.io/),
[Konrad Schindler](https://scholar.google.com/citations?user=FZuNgqIAAAAJ&hl=en )

We present Marigold, a diffusion model and associated fine-tuning protocol for monocular depth estimation. Its core principle is to leverage the rich visual knowledge stored in modern generative image models. Our model, derived from Stable Diffusion and fine-tuned with synthetic data, can zero-shot transfer to unseen data, offering state-of-the-art monocular depth estimation results.

![teaser](doc/teaser_collage_transparant.png)


## 📢 News

2023-12-04: Upload [arxiv]() paper.

2023-12-04: Release inference code.


## 🛠️ Setup

This code has been tested on:

- Python 3.10.12, PyTorch 2.0.1, CUDA 11.7, GeForce RTX 3090
- python 3.10.4, Pytorch 2.0.1, CUDA 11.7, GeForce RTX 4090

Clone repository

```bash
git clone git@github.com:prs-eth/Marigold.git
cd Marigold
```

Setup Python environment

```bash
python -m venv venv/marigold
source venv/marigold/bin/activate
pip install -r requirements.txt
```

Download checkpoint

```bash
bash script/download_weights.sh
```

## 🚀 Inference on in-the-wild images

📷 Download sample images

```bash
bash script/download_sample_data.sh
```

🎮 Run inference

```bash
python run.py \
--input_rgb_dir data/in-the-wild_example\
--output_dir output/in-the-wild_example
```

⚙️ Inference settings

- The inference script by default will resize the input images and resize back to the original resolution.

- `--resize_to_max_res`: The maximum edge length of resized input image. Default: 768.
- `--not_resize_input`: If given, will not resize the input image.
- `--not_resize_output`: If given, will not resize the output image back to the original resolution. Only valid without `--not_resize_input` option.

- Trade-offs between **accuracy** and **speed** (for both options, larger value results in more accurate results at the cost of slower inference speed.)

- `--n_infer`: Number of inference passes to be ensembled. Default: 10.
- `--denoise_steps`: Number of diffusion denoising steps of each inference pass. Default: 10.

- `--seed`: Random seed, can be set to ensure reproducibility. Default: None (using current time as random seed).
- `--depth_cmap`: Colormap used to colorize the depth prediction. Default: Spectral.

## 🎓 Citation

```bibtex
@misc{ke2023marigold,
author = {Ke, Bingxin and Obukhov, Anton and Huang, Shengyu and Metzger, Nando and Daudt, Rodrigo Caye and Schindler, Konrad},
title = {Repurposing Diffusion-Based Image Generators for Monocular Depth Estimation},
year = {2023},
}
```
[<img src="doc/badges/badge-pdf.svg" height="20"/>]()

## License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

[<img src="doc/badges/badge-license.svg" height="20"/>](http://creativecommons.org/licenses/by-nc-sa/4.0/)
33 changes: 33 additions & 0 deletions doc/badges/badge-colab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions doc/badges/badge-docker.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions doc/badges/badge-license.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions doc/badges/badge-pdf.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
129 changes: 129 additions & 0 deletions doc/badges/badge-website.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/teaser_collage_transparant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit dfc0e2f

Please sign in to comment.