Giter VIP home page Giter VIP logo

stable-dreamfusion's Introduction

Stable-Dreamfusion

A pytorch implementation of the text-to-3D model Dreamfusion, powered by the Stable Diffusion text-to-2D model.

ADVERTISEMENT: Please check out threestudio for recent improvements and better implementation in 3D content generation!

NEWS (2023.6.12):

image-to-3d-0123.mp4
text-to-3d.mp4

Colab notebooks:

  • Instant-NGP backbone (-O): Instant-NGP Backbone

  • Vanilla NeRF backbone (-O2): Vanilla Backbone

Important Notice

This project is a work-in-progress, and contains lots of differences from the paper. The current generation quality cannot match the results from the original paper, and many prompts still fail badly!

Notable differences from the paper

  • Since the Imagen model is not publicly available, we use Stable Diffusion to replace it (implementation from diffusers). Different from Imagen, Stable-Diffusion is a latent diffusion model, which diffuses in a latent space instead of the original image space. Therefore, we need the loss to propagate back from the VAE's encoder part too, which introduces extra time cost in training.
  • We use the multi-resolution grid encoder to implement the NeRF backbone (implementation from torch-ngp), which enables much faster rendering (~10FPS at 800x800).
  • We use the Adan optimizer as default.

Install

git clone https://github.com/ashawkey/stable-dreamfusion.git
cd stable-dreamfusion

Optional: create a python virtual environment

To avoid python package conflicts, we recommend using a virtual environment, e.g.: using conda or venv:

python -m venv venv_stable-dreamfusion
source venv_stable-dreamfusion/bin/activate # you need to repeat this step for every new terminal

Install with pip

pip install -r requirements.txt

Download pre-trained models

To use image-conditioned 3D generation, you need to download some pretrained checkpoints manually:

  • Zero-1-to-3 for diffusion backend. We use zero123-xl.ckpt by default, and it is hard-coded in guidance/zero123_utils.py.
    cd pretrained/zero123
    wget https://zero123.cs.columbia.edu/assets/zero123-xl.ckpt
  • Omnidata for depth and normal prediction. These ckpts are hardcoded in preprocess_image.py.
    mkdir pretrained/omnidata
    cd pretrained/omnidata
    # assume gdown is installed
    gdown '1Jrh-bRnJEjyMCS7f-WsaFlccfPjJPPHI&confirm=t' # omnidata_dpt_depth_v2.ckpt
    gdown '1wNxVO4vVbDEMEpnAi_jwQObf2MFodcBR&confirm=t' # omnidata_dpt_normal_v2.ckpt

To use DeepFloyd-IF, you need to accept the usage conditions from hugging face, and login with huggingface-cli login in command line.

For DMTet, we port the pre-generated 32/64/128 resolution tetrahedron grids under tets. The 256 resolution one can be found here.

Build extension (optional)

By default, we use load to build the extension at runtime. We also provide the setup.py to build each extension:

cd stable-dreamfusion

# install all extension modules
bash scripts/install_ext.sh

# if you want to install manually, here is an example:
pip install ./raymarching # install to python path (you still need the raymarching/ folder, since this only installs the built extension.)

Taichi backend (optional)

Use Taichi backend for Instant-NGP. It achieves comparable performance to CUDA implementation while No CUDA build is required. Install Taichi with pip:

pip install -i https://pypi.taichi.graphics/simple/ taichi-nightly

Trouble Shooting:

  • we assume working with the latest version of all dependencies, if you meet any problems from a specific dependency, please try to upgrade it first (e.g., pip install -U diffusers). If the problem still holds, reporting a bug issue will be appreciated!
  • [F glutil.cpp:338] eglInitialize() failed Aborted (core dumped): this usually indicates problems in OpenGL installation. Try to re-install Nvidia driver, or use nvidia-docker as suggested in #131 if you are using a headless server.
  • TypeError: xxx_forward(): incompatible function arguments: this happens when we update the CUDA source and you used setup.py to install the extensions earlier. Try to re-install the corresponding extension (e.g., pip install ./gridencoder).

Tested environments

  • Ubuntu 22 with torch 1.12 & CUDA 11.6 on a V100.

Usage

First time running will take some time to compile the CUDA extensions.

#### stable-dreamfusion setting

### Instant-NGP NeRF Backbone
# + faster rendering speed
# + less GPU memory (~16G)
# - need to build CUDA extensions (a CUDA-free Taichi backend is available)

## train with text prompt (with the default settings)
# `-O` equals `--cuda_ray --fp16`
# `--cuda_ray` enables instant-ngp-like occupancy grid based acceleration.
python main.py --text "a hamburger" --workspace trial -O

# reduce stable-diffusion memory usage with `--vram_O`
# enable various vram savings (https://huggingface.co/docs/diffusers/optimization/fp16).
python main.py --text "a hamburger" --workspace trial -O --vram_O

# You can collect arguments in a file. You can override arguments by specifying them after `--file`. Note that quoted strings can't be loaded from .args files...
python main.py --file scripts/res64.args --workspace trial_awesome_hamburger --text "a photo of an awesome hamburger"

# use CUDA-free Taichi backend with `--backbone grid_taichi`
python3 main.py --text "a hamburger" --workspace trial -O --backbone grid_taichi

# choose stable-diffusion version (support 1.5, 2.0 and 2.1, default is 2.1 now)
python main.py --text "a hamburger" --workspace trial -O --sd_version 1.5

# use a custom stable-diffusion checkpoint from hugging face:
python main.py --text "a hamburger" --workspace trial -O --hf_key andite/anything-v4.0

# use DeepFloyd-IF for guidance (experimental):
python main.py --text "a hamburger" --workspace trial -O --IF
python main.py --text "a hamburger" --workspace trial -O --IF --vram_O # requires ~24G GPU memory

# we also support negative text prompt now:
python main.py --text "a rose" --negative "red" --workspace trial -O

## after the training is finished:
# test (exporting 360 degree video)
python main.py --workspace trial -O --test
# also save a mesh (with obj, mtl, and png texture)
python main.py --workspace trial -O --test --save_mesh
# test with a GUI (free view control!)
python main.py --workspace trial -O --test --gui

### Vanilla NeRF backbone
# + pure pytorch, no need to build extensions!
# - slow rendering speed
# - more GPU memory

## train
# `-O2` equals `--backbone vanilla`
python main.py --text "a hotdog" --workspace trial2 -O2

# if CUDA OOM, try to reduce NeRF sampling steps (--num_steps and --upsample_steps)
python main.py --text "a hotdog" --workspace trial2 -O2 --num_steps 64 --upsample_steps 0

## test
python main.py --workspace trial2 -O2 --test
python main.py --workspace trial2 -O2 --test --save_mesh
python main.py --workspace trial2 -O2 --test --gui # not recommended, FPS will be low.

### DMTet finetuning

## use --dmtet and --init_with <nerf checkpoint> to finetune the mesh at higher reslution
python main.py -O --text "a hamburger" --workspace trial_dmtet --dmtet --iters 5000 --init_with trial/checkpoints/df.pth

## init dmtet with a mesh to generate texture
# require install of cubvh: pip install git+https://github.com/ashawkey/cubvh
# remove --lock_geo to also finetune geometry, but performance may be bad.
python main.py -O --text "a white bunny with red eyes" --workspace trial_dmtet_mesh --dmtet --iters 5000 --init_with ./data/bunny.obj --lock_geo

## test & export the mesh
python main.py -O --text "a hamburger" --workspace trial_dmtet --dmtet --iters 5000 --test --save_mesh

## gui to visualize dmtet
python main.py -O --text "a hamburger" --workspace trial_dmtet --dmtet --iters 5000 --test --gui

### Image-conditioned 3D Generation

## preprocess input image
# note: the results of image-to-3D is dependent on zero-1-to-3's capability. For best performance, the input image should contain a single front-facing object, it should have square aspect ratio, with <1024 pixel resolution. Check the examples under ./data.
# this will exports `<image>_rgba.png`, `<image>_depth.png`, and `<image>_normal.png` to the directory containing the input image.
python preprocess_image.py <image>.png
python preprocess_image.py <image>.png --border_ratio 0.4 # increase border_ratio if the center object appears too large and results are unsatisfying.

## zero123 train
# pass in the processed <image>_rgba.png by --image and do NOT pass in --text to enable zero-1-to-3 backend.
python main.py -O --image <image>_rgba.png --workspace trial_image --iters 5000

# if the image is not exactly front-view (elevation = 0), adjust default_polar (we use polar from 0 to 180 to represent elevation from 90 to -90)
python main.py -O --image <image>_rgba.png --workspace trial_image --iters 5000 --default_polar 80

# by default we leverage monocular depth estimation to aid image-to-3d, but if you find the depth estimation inaccurate and harms results, turn it off by:
python main.py -O --image <image>_rgba.png --workspace trial_image --iters 5000 --lambda_depth 0

python main.py -O --image <image>_rgba.png --workspace trial_image_dmtet --dmtet --init_with trial_image/checkpoints/df.pth

## zero123 with multiple images
python main.py -O --image_config config/<config>.csv --workspace trial_image --iters 5000

## render <num> images per batch (default 1)
python main.py -O --image_config config/<config>.csv --workspace trial_image --iters 5000 --batch_size 4

# providing both --text and --image enables stable-diffusion backend (similar to make-it-3d)
python main.py -O --image hamburger_rgba.png --text "a DSLR photo of a delicious hamburger" --workspace trial_image_text --iters 5000

python main.py -O --image hamburger_rgba.png --text "a DSLR photo of a delicious hamburger" --workspace trial_image_text_dmtet --dmtet --init_with trial_image_text/checkpoints/df.pth

## test / visualize
python main.py -O --image <image>_rgba.png --workspace trial_image_dmtet --dmtet --test --save_mesh
python main.py -O --image <image>_rgba.png --workspace trial_image_dmtet --dmtet --test --gui

### Debugging

# Can save guidance images for debugging purposes. These get saved in trial_hamburger/guidance.
# Warning: this slows down training considerably and consumes lots of disk space!
python main.py --text "a hamburger" --workspace trial_hamburger -O --vram_O --save_guidance --save_guidance_interval 5 # save every 5 steps

For example commands, check scripts.

For advanced tips and other developing stuff, check Advanced Tips.

Evalutation

Reproduce the paper CLIP R-precision evaluation

After the testing part in the usage, the validation set containing projection from different angle is generated. Test the R-precision between prompt and the image.(R=1)

python r_precision.py --text "a snake is flying in the sky" --workspace snake_HQ --latest ep0100 --mode depth --clip clip-ViT-B-16

Acknowledgement

This work is based on an increasing list of amazing research works and open-source projects, thanks a lot to all the authors for sharing!

  • DreamFusion: Text-to-3D using 2D Diffusion

    @article{poole2022dreamfusion,
        author = {Poole, Ben and Jain, Ajay and Barron, Jonathan T. and Mildenhall, Ben},
        title = {DreamFusion: Text-to-3D using 2D Diffusion},
        journal = {arXiv},
        year = {2022},
    }
    
  • Magic3D: High-Resolution Text-to-3D Content Creation

    @inproceedings{lin2023magic3d,
       title={Magic3D: High-Resolution Text-to-3D Content Creation},
       author={Lin, Chen-Hsuan and Gao, Jun and Tang, Luming and Takikawa, Towaki and Zeng, Xiaohui and Huang, Xun and Kreis, Karsten and Fidler, Sanja and Liu, Ming-Yu and Lin, Tsung-Yi},
       booktitle={IEEE Conference on Computer Vision and Pattern Recognition ({CVPR})},
       year={2023}
     }
    
  • Zero-1-to-3: Zero-shot One Image to 3D Object

    @misc{liu2023zero1to3,
        title={Zero-1-to-3: Zero-shot One Image to 3D Object},
        author={Ruoshi Liu and Rundi Wu and Basile Van Hoorick and Pavel Tokmakov and Sergey Zakharov and Carl Vondrick},
        year={2023},
        eprint={2303.11328},
        archivePrefix={arXiv},
        primaryClass={cs.CV}
    }
    
  • Perp-Neg: Re-imagine the Negative Prompt Algorithm: Transform 2D Diffusion into 3D, alleviate Janus problem and Beyond

    @article{armandpour2023re,
      title={Re-imagine the Negative Prompt Algorithm: Transform 2D Diffusion into 3D, alleviate Janus problem and Beyond},
      author={Armandpour, Mohammadreza and Zheng, Huangjie and Sadeghian, Ali and Sadeghian, Amir and Zhou, Mingyuan},
      journal={arXiv preprint arXiv:2304.04968},
      year={2023}
    }
    
  • RealFusion: 360° Reconstruction of Any Object from a Single Image

    @inproceedings{melaskyriazi2023realfusion,
        author = {Melas-Kyriazi, Luke and Rupprecht, Christian and Laina, Iro and Vedaldi, Andrea},
        title = {RealFusion: 360 Reconstruction of Any Object from a Single Image},
        booktitle={CVPR}
        year = {2023},
        url = {https://arxiv.org/abs/2302.10663},
    }
    
  • Fantasia3D: Disentangling Geometry and Appearance for High-quality Text-to-3D Content Creation

    @article{chen2023fantasia3d,
        title={Fantasia3D: Disentangling Geometry and Appearance for High-quality Text-to-3D Content Creation},
        author={Rui Chen and Yongwei Chen and Ningxin Jiao and Kui Jia},
        journal={arXiv preprint arXiv:2303.13873},
        year={2023}
    }
    
  • Make-It-3D: High-Fidelity 3D Creation from A Single Image with Diffusion Prior

    @article{tang2023make,
        title={Make-It-3D: High-Fidelity 3D Creation from A Single Image with Diffusion Prior},
        author={Tang, Junshu and Wang, Tengfei and Zhang, Bo and Zhang, Ting and Yi, Ran and Ma, Lizhuang and Chen, Dong},
        journal={arXiv preprint arXiv:2303.14184},
        year={2023}
    }
    
  • Stable Diffusion and the diffusers library.

    @misc{rombach2021highresolution,
        title={High-Resolution Image Synthesis with Latent Diffusion Models},
        author={Robin Rombach and Andreas Blattmann and Dominik Lorenz and Patrick Esser and Björn Ommer},
        year={2021},
        eprint={2112.10752},
        archivePrefix={arXiv},
        primaryClass={cs.CV}
    }
    
    @misc{von-platen-etal-2022-diffusers,
        author = {Patrick von Platen and Suraj Patil and Anton Lozhkov and Pedro Cuenca and Nathan Lambert and Kashif Rasul and Mishig Davaadorj and Thomas Wolf},
        title = {Diffusers: State-of-the-art diffusion models},
        year = {2022},
        publisher = {GitHub},
        journal = {GitHub repository},
        howpublished = {\url{https://github.com/huggingface/diffusers}}
    }
    
  • The GUI is developed with DearPyGui.

  • Puppy image from : https://www.pexels.com/photo/high-angle-photo-of-a-corgi-looking-upwards-2664417/

  • Anya images from : https://www.goodsmile.info/en/product/13301/POP+UP+PARADE+Anya+Forger.html

Citation

If you find this work useful, a citation will be appreciated via:

@misc{stable-dreamfusion,
    Author = {Jiaxiang Tang},
    Year = {2022},
    Note = {https://github.com/ashawkey/stable-dreamfusion},
    Title = {Stable-dreamfusion: Text-to-3D with Stable-diffusion}
}

stable-dreamfusion's People

Contributors

abesmon avatar ashawkey avatar claforte avatar elliottzheng avatar eltociear avatar erizmr avatar flobotics avatar hodor avatar jik-ai avatar jogloran avatar johnrobinsn avatar justinfungi avatar mathieutuli avatar nside avatar rezaarmand avatar tobbelobb avatar voletiv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stable-dreamfusion's Issues

About learning rate and camera sampling

Thanks for your contribution! I found some problems when using the code:

  1. The learning rate is supposed to decay to 0.01xinitial_lr at the end but it almost never changed because the scheduler is updated every epoch instead of every step (BTW, why don't you use the cosine annealing as in the paper?)
  2. In the paper, the authors mentioned that sampling camera position uniformly by angle leads to oversampling on the overhead view. So by 50% chance, they sample uniformly on the sphere surface. Seems like it is not implemented.
  3. As for the w(t). The author mentioned that "we absorb the constant alpha_t = delta z_t / delta x into w(t)". I think it means that since alpha(t) can be considered as part of w(t), we can simply ignore it and choose whatever w(t) we want. So that would mean w(t)=sigma_t^2. correct me if I am wrong:)

AttributeError: 'DiagonalGaussianDistribution' object has no attribute 'latent_dist'

ou have run `huggingface-cli login`.
[INFO] loading stable diffusion...
[INFO] loaded stable diffusion!
[INFO] Trainer: df | 2022-10-13_13-00-38 | cuda | fp16 | trial_dog
[INFO] #parameters: 12249015
[INFO] Loading latest checkpoint ...
[WARN] No checkpoint found, model randomly initialized.
==> Start Training trial_dog Epoch 1, lr=0.010000 ...
  0% 0/100 [00:00<?, ?it/s]Traceback (most recent call last):
  File "main.py", line 153, in <module>
    trainer.train(train_loader, valid_loader, max_epoch)
  File "/data/GAN/stable-dreamfusion/nerf/utils.py", line 458, in train
    self.train_one_epoch(train_loader)
  File "/data/GAN/stable-dreamfusion/nerf/utils.py", line 678, in train_one_epoch
    pred_rgbs, pred_ws, loss = self.train_step(data)
  File "/data/GAN/stable-dreamfusion/nerf/utils.py", line 358, in train_step
    loss = self.guidance.train_step(text_z, pred_rgb)
  File "/data/GAN/stable-dreamfusion/nerf/sd.py", line 79, in train_step
    latents = self.encode_imgs(pred_rgb_512)
  File "/data/GAN/stable-dreamfusion/nerf/sd.py", line 153, in encode_imgs
    posterior = self.vae.encode(imgs).latent_dist
AttributeError: 'DiagonalGaussianDistribution' object has no attribute 'latent_dist'
  0% 0/100 [00:00<?, ?it/s]

not able to install extensions

The detected CUDA version (11.5) mismatches the version that was used to compile PyTorch (10.2). Please make sure to use the same CUDA versions.

But do not know how to fix it. Ubuntu 22.04

Classifier-free guidance

Hi,

Just going over the code line-by-line and checking things ;)
this line

I think

noise_pred = noise_pred_uncond + guidance_scale * (noise_pred_text - noise_pred_uncond)

should be

noise_pred = noise_pred_text + guidance_scale * (noise_pred_text - noise_pred_uncond)

to match the equation of the paper

Happy to do a PR if you confirm it needs to be change.

Thanks,

Screenshot 2022-10-10 at 18 52 22

howto control time spend doing its work

hi,
i used the example with "a hambuger" text-prompt and used --iter=100 , but it run for over 6 hours until i stopped it. There is no epoch or steps command line argument ?

How can i control the "time" it spend doing a text-prompt ? What is the "average" time it needs, todo text-prompt "a hambuger" ?

thx

--save_mesh not saving mesh and --gui only showing empty scene

Hey, Whenever I run a prompt, it gives me the correct pngs and mp4 of a model rotating and all of that, but I cannot save the mesh. It´s not saving any obj and the GUI prompt only shows an empty scene. I tried the suggestions with increasing the albedo_iterations and all but... still no mesh. Any ideas?
Windows 11, Python 3.9.13, NVidia RTX A6000

Share good results of text prompt

I'm running this project on a AWS P3 instance, took around 50 minutes and i'm trying to find some text that build good mesh.
Please, anyone can share some text that generate something at least acceptable like the "a hamburger"?
For example, "tiger wearing sunglasses, riding a motorcycle" generate only a cloud.

no module: huggingface_hub

running the first cell gives me this:

ModuleNotFoundError Traceback (most recent call last)
in
1 #@title login to huggingface to download stable diffusion
----> 2 from huggingface_hub import notebook_login
3 from google.colab import output
4
5 output.enable_custom_widget_manager()

ModuleNotFoundError: No module named 'huggingface_hub'

The .obj model cannot show texture

Hi, dear author, thanks for you awesome work!

I follow the usage and run "python main.py --text "a hamburger" --workspace trial -O"
after the training is finished run "python main.py --workspace trial -O --test --save_mesh" in order to get the textured mesh.

The .obj .png .mtl files was successful saved. But I open the .obj in blender, it only show the mesh below(no texture on it)

The shape of the mesh looks correct, the .png .mtl both correct, the results of depth.mp4 and rgb.mp4 are correct.

The only problem is the mesh don't have texture. I test on local and colab, same result. Did I miss something? Thank you!
image

Linker issue when building the raymarching extensions

I've got an issue when I try to build the raymarching module, whereas all the others build cleanly.

The exact output I see is here:

"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX86\x64\link.exe" /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Anaconda3\envs\dream\lib\site-packages\torch\lib "/LIBPATH:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\lib/x64" /LIBPATH:C:\Anaconda3\envs\dream\libs /LIBPATH:C:\Anaconda3\envs\dream /LIBPATH:C:\Anaconda3\envs\dream\PCbuild\amd64 "/LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\ATLMFC\lib\x64" "/LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\\lib\10.0.19041.0\\um\x64" c10.lib torch.lib torch_cpu.lib torch_python.lib cudart.lib c10_cuda.lib torch_cuda_cu.lib torch_cuda_cpp.lib /EXPORT:PyInit__raymarching D:\Work\ML\3070\stable-dreamfusion\raymarching\build\temp.win-amd64-cpython-39\Release\Work\ML\3070\stable-dreamfusion\raymarching\src\bindings.obj D:\Work\ML\3070\stable-dreamfusion\raymarching\build\temp.win-amd64-cpython-39\Release\Work\ML\3070\stable-dreamfusion\raymarching\src\raymarching.obj /OUT:build\lib.win-amd64-cpython-39\_raymarching.cp39-win_amd64.pyd /IMPLIB:D:\Work\ML\3070\stable-dreamfusion\raymarching\build\temp.win-amd64-cpython-39\Release\Work\ML\3070\stable-dreamfusion\raymarching\src\_raymarching.cp39-win_amd64.lib
   Creating library D:\Work\ML\3070\stable-dreamfusion\raymarching\build\temp.win-amd64-cpython-39\Release\Work\ML\3070\stable-dreamfusion\raymarching\src\_raymarching.cp39-win_amd64.lib and object D:\Work\ML\3070\stable-dreamfusion\raymarching\build\temp.win-amd64-cpython-39\Release\Work\ML\3070\stable-dreamfusion\raymarching\src\_raymarching.cp39-win_amd64.exp
bindings.obj : error LNK2001: unresolved external symbol "void __cdecl composite_rays(unsigned int,unsigned int,float,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor)" (?composite_rays@@YAXIIMVTensor@at@@0000000@Z)
  Hint on symbols that are defined and could potentially match:
    "void __cdecl composite_rays(unsigned int,unsigned int,float,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor)" (?composite_rays@@YAXIIMVTensor@at@@0V12@11000@Z)
build\lib.win-amd64-cpython-39\_raymarching.cp39-win_amd64.pyd : fatal error LNK1120: 1 unresolved externals

The main issue looks to be related to the composite_rays() method. When it's linking the object file, the namespace suffix looks to be different to what it expects.

The symbol it wants is:
(?composite_rays@@YAXIIMVTensor@at@@0000000@Z)
whereas the symbol it has is:
(?composite_rays@@YAXIIMVTensor@at@@0V12@11000@Z)

I don't know why it's inserting the extra 0V12@.

I've tried some obvious things like playing with the arguments, but since shencoder, freqencoder and gridencoder all work, I'm stuck, as I'm not particularly familiar with the CUDA build process.

I've got CUDA 11.8 installed, but am using 11.6 within the Anaconda/Python environment, and Python is 3.9.13. PyTorch is 1.12.1.

I understand from the README that this has been tested on Linux, so this might be a long shot.

Question about static thresholding

Hi, firstly thank you so much for sharing this wonderful implementation code!

I wonder why you commented static thresholding line in the sd.py below.

# grad = grad.clamp(-1, 1)

As you mentioned in the comment above this line, I've known that static thresholding is essential to sampling with large guidance scale for stable training... Is there any reason you've finally commented that line?

Thanks in advance.

Problems for test

Have a problems for test the colab, I think the problem is for the models... can help me? , Tnks🙏 :

Namespace(H=800, O=True, O2=False, W=800, albedo_iters=1000, angle_front=60, angle_overhead=30, backbone='grid', bg_radius=1.4, bound=1, ckpt='scratch', cuda_ray=True, density_thresh=10, dir_text=True, dt_gamma=0, eval_interval=10, fovy=60, fovy_range=[40, 70], fp16=True, gui=False, guidance='stable-diffusion', h=64, iters=5000, jitter_pose=False, lambda_entropy=0.0001, lambda_opacity=0, lambda_orient=0.01, lambda_smooth=0, light_phi=0, light_theta=60, lr=0.001, max_ray_batch=4096, max_spp=1, max_steps=1024, min_near=0.1, negative='', negative_dir_text=True, num_steps=64, radius=3, radius_range=[1.0, 1.5], save_mesh=True, seed=0, test=False, text='plant ', update_extra_interval=16, upsample_steps=64, w=64, workspace='trial')
NeRFNetwork(
(encoder): GridEncoder: input_dim=3 num_levels=16 level_dim=2 resolution=16 -> 2048 per_level_scale=1.3819 params=(903480, 2) gridtype=tiled align_corners=False
(sigma_net): MLP(
(net): ModuleList(
(0): Linear(in_features=32, out_features=64, bias=True)
(1): Linear(in_features=64, out_features=64, bias=True)
(2): Linear(in_features=64, out_features=4, bias=True)
)
)
(encoder_bg): FreqEncoder: input_dim=3 degree=6 output_dim=39
(bg_net): MLP(
(net): ModuleList(
(0): Linear(in_features=39, out_features=64, bias=True)
(1): Linear(in_features=64, out_features=3, bias=True)
)
)
)
[INFO] try to load hugging face access token from the default place, make sure you have run huggingface-cli login.
[INFO] loading stable diffusion...

HTTPError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/huggingface_hub/utils/_errors.py in hf_raise_for_status(response, endpoint_name)
212 try:
--> 213 response.raise_for_status()
214 except HTTPError as e:

7 frames
HTTPError: 403 Client Error: Forbidden for url: https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/vae/diffusion_pytorch_model.bin

The above exception was the direct cause of the following exception:

HfHubHTTPError Traceback (most recent call last)
HfHubHTTPError: <class 'requests.exceptions.HTTPError'> (Request ID: ir0-cnJcGTioLkO4XBr0C)

During handling of the above exception, another exception occurred:

OSError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/diffusers/modeling_utils.py in from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
358 except HTTPError as err:
359 raise EnvironmentError(
--> 360 "There was a specific connection error when trying to load"
361 f" {pretrained_model_name_or_path}:\n{err}"
362 )

OSError: There was a specific connection error when trying to load runwayml/stable-diffusion-v1-5:
<class 'requests.exceptions.HTTPError'> (Request ID: ir0-cnJcGTioLkO4XBr0C)

Using SD Embeddings

Curious if it is possible to use textual inversion embeddings from stable-diffusion, and if so how I would go about doing so.

Is a WSL2 + nvidia-docker environment supported?

Hello,

I tried to install stable-dreamfusion in a WSL2 + nvidia-docker environment, the following error occurred.
The procedure of Build image in Docker/README.md has been executed.

 => CACHED [13/16] RUN pip3 install git+https://github.com/NVlabs/nvdiffrast/                                      0.0s
 => ERROR [14/16] RUN pip3 install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch        18.3s
------
 > [14/16] RUN pip3 install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch:
#17 1.107 Collecting git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
#17 1.107   Cloning https://github.com/NVlabs/tiny-cuda-nn/ to /tmp/pip-req-build-1p1uv4so
#17 1.107   Running command git clone -q https://github.com/NVlabs/tiny-cuda-nn/ /tmp/pip-req-build-1p1uv4so
#17 6.520   Running command git submodule update --init --recursive -q
#17 18.23     ERROR: Command errored out with exit status 1:
#17 18.23      command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-1p1uv4so/bindings/torch/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-1p1uv4so/bindings/torch/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-req-build-1p1uv4so/bindings/torch/pip-egg-info
#17 18.23          cwd: /tmp/pip-req-build-1p1uv4so/bindings/torch
#17 18.23     Complete output (7 lines):
#17 18.23     Traceback (most recent call last):
#17 18.23       File "<string>", line 1, in <module>
#17 18.23       File "/tmp/pip-req-build-1p1uv4so/bindings/torch/setup.py", line 30, in <module>
#17 18.23         raise EnvironmentError("Unknown compute capability. Specify the target compute capabilities in the TCNN_CUDA_ARCHITECTURES environment variable or install PyTorch with the CUDA backend to detect it automatically.")
#17 18.23     OSError: Unknown compute capability. Specify the target compute capabilities in the TCNN_CUDA_ARCHITECTURES environment variable or install PyTorch with the CUDA backend to detect it automatically.
#17 18.23     No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda'
#17 18.23     Building PyTorch extension for tiny-cuda-nn version 1.6
#17 18.23     ----------------------------------------
#17 18.31 ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
------
executor failed running [/bin/sh -c pip3 install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch]: exit code: 1

PIP "You are using the wrong version" even though the right version is installed

Whenever I run this:
bash scripts/install_ext.sh

I get this error in 4 variations for the 4 things it is trying to build:

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-lNLBKq-build/
You are using pip version 8.1.1, however version 22.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

My PIP version is up to date:

pip --version
pip 21.2.4 from C:\Users\Tom_New\miniconda3\lib\site-packages\pip (python 3.9)

RuntimeError: CUDA out of memory.

root@Ie640bd7d900d0100b:/hy-tmp/stable-dreamfusion# python main.py --text "a hamburger" --workspace trial -O
Namespace(H=800, O=True, O2=False, W=800, albedo_iters=1000, angle_front=60, angle_overhead=30, backbone='grid', bg_radius=1.4, bound=1, ckpt='latest', cuda_ray=True, density_thresh=10, dir_text=True, dt_gamma=0, eval_interval=10, fovy=60, fovy_range=[40, 70], fp16=True, gui=False, guidance='stable-diffusion', h=64, iters=10000, jitter_pose=False, lambda_entropy=0.0001, lambda_opacity=0, lambda_orient=0.01, light_phi=0, light_theta=60, lr=0.001, max_ray_batch=4096, max_spp=1, max_steps=1024, min_near=0.1, num_steps=64, radius=3, radius_range=[1.0, 1.5], save_mesh=False, seed=0, test=False, text='a hamburger', update_extra_interval=16, upsample_steps=64, w=64, workspace='trial')
NeRFNetwork(
  (encoder): GridEncoder: input_dim=3 num_levels=16 level_dim=2 resolution=16 -> 2048 per_level_scale=1.3819 params=(6119864, 2) gridtype=tiled align_corners=False
  (sigma_net): MLP(
    (net): ModuleList(
      (0): Linear(in_features=32, out_features=64, bias=True)
      (1): Linear(in_features=64, out_features=64, bias=True)
      (2): Linear(in_features=64, out_features=4, bias=True)
    )
  )
  (encoder_bg): FreqEncoder: input_dim=3 degree=6 output_dim=39
  (bg_net): MLP(
    (net): ModuleList(
      (0): Linear(in_features=39, out_features=64, bias=True)
      (1): Linear(in_features=64, out_features=3, bias=True)
    )
  )
)
[INFO] loaded hugging face access token from ./TOKEN!
[INFO] loading stable diffusion...
[INFO] loaded stable diffusion!
[INFO] Trainer: df | 2022-10-17_17-51-17 | cuda | fp16 | trial
[INFO] #parameters: 12249015
[INFO] Loading latest checkpoint ...
[WARN] No checkpoint found, model randomly initialized.
==> Start Training trial Epoch 1, lr=0.010000 ...
  0% 0/100 [00:00<?, ?it/s]Traceback (most recent call last):
  File "main.py", line 153, in <module>
    trainer.train(train_loader, valid_loader, max_epoch)
  File "/hy-tmp/stable-dreamfusion/nerf/utils.py", line 468, in train
    self.train_one_epoch(train_loader)
  File "/hy-tmp/stable-dreamfusion/nerf/utils.py", line 688, in train_one_epoch
    pred_rgbs, pred_ws, loss = self.train_step(data)
  File "/hy-tmp/stable-dreamfusion/nerf/utils.py", line 365, in train_step
    loss = self.guidance.train_step(text_z, pred_rgb)
  File "/hy-tmp/stable-dreamfusion/nerf/sd.py", line 90, in train_step
    noise_pred = self.unet(latent_model_input, t, encoder_hidden_states=text_embeddings).sample
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/diffusers/models/unet_2d_condition.py", line 296, in forward
    sample, res_samples = downsample_block(
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/diffusers/models/unet_blocks.py", line 563, in forward
    hidden_states = attn(hidden_states, context=encoder_hidden_states)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/diffusers/models/attention.py", line 162, in forward
    hidden_states = block(hidden_states, context=context)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/diffusers/models/attention.py", line 211, in forward
    hidden_states = self.attn1(self.norm1(hidden_states)) + hidden_states
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/diffusers/models/attention.py", line 283, in forward
    hidden_states = self._attention(query, key, value)
  File "/usr/local/lib/python3.8/dist-packages/diffusers/models/attention.py", line 292, in _attention
    attention_probs = attention_scores.softmax(dim=-1)
RuntimeError: CUDA out of memory. Tried to allocate 1024.00 MiB (GPU 0; 9.78 GiB total capacity; 7.44 GiB already allocated; 644.06 MiB free; 7.50 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
  0% 0/100 [00:01<?, ?it/s]

CUDA_HOME environment variable is not set

Hi,

When I try running this from the readme usage section:
python main.py --text "a hamburger" --workspace trial -O

I get this error:
OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.

What should I do about this?

Here is the full error:

C:\Users\Matthew\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\amp\autocast_mode.py:198: UserWarning: User provided device_type of 'cuda', but CUDA is not available. Disabling
  warnings.warn('User provided device_type of \'cuda\', but CUDA is not available. Disabling')
Traceback (most recent call last):
  File "D:\CodeProjects\VisualStudioCode\Other\DreamFusion\stable-dreamfusion\raymarching\raymarching.py", line 10, in <module>
    import _raymarching as _backend
ModuleNotFoundError: No module named '_raymarching'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 84, in <module>
    from nerf.network_grid import NeRFNetwork
  File "D:\CodeProjects\VisualStudioCode\Other\DreamFusion\stable-dreamfusion\nerf\network_grid.py", line 6, in <module>
    from .renderer import NeRFRenderer
  File "D:\CodeProjects\VisualStudioCode\Other\DreamFusion\stable-dreamfusion\nerf\renderer.py", line 12, in <module>
    import raymarching
  File "D:\CodeProjects\VisualStudioCode\Other\DreamFusion\stable-dreamfusion\raymarching\__init__.py", line 1, in <module>
    from .raymarching import *
  File "D:\CodeProjects\VisualStudioCode\Other\DreamFusion\stable-dreamfusion\raymarching\raymarching.py", line 12, in <module>
    from .backend import _backend
  File "D:\CodeProjects\VisualStudioCode\Other\DreamFusion\stable-dreamfusion\raymarching\backend.py", line 31, in <module>
    _backend = load(name='_raymarching',
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\utils\cpp_extension.py", line 1202, in load
    return _jit_compile(
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\utils\cpp_extension.py", line 1425, in _jit_compile
    _write_ninja_file_and_build_library(
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\utils\cpp_extension.py", line 1514, in _write_ninja_file_and_build_library        
    extra_ldflags = _prepare_ldflags(
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\utils\cpp_extension.py", line 1617, in _prepare_ldflags
    extra_ldflags.append(f'/LIBPATH:{_join_cuda_home("lib/x64")}')
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\utils\cpp_extension.py", line 2125, in _join_cuda_home
    raise EnvironmentError('CUDA_HOME environment variable is not set. '
OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.

A cloud of smoke as a result (empty result)

Hi, @ashawkey thanks for your awesome work.

Could you help me please. I can't get normal result.
Every time I get smoke, not normal mesh.

df_ep0100_rgb.mp4
df_ep0050_rgb.mp4

I tried to decrease Lambda_entropy form 1e-4 to 1e-7, but it didn't help.

Снимок экрана 2022-10-23 в 07 26 25

My colab params:

Снимок экрана 2022-10-23 в 07 26 33

Thanks for advice.

BR, Demian

Not able to import dearpygui._dearpygui

When running main.py I get the following error:

 File "main.py", line 8, in <module>
    from nerf.gui import NeRFGUI
  File "nerf/gui.py", line 4, in <module>
    import dearpygui.dearpygui as dpg
  File "lib/python3.9/site-packages/dearpygui/dearpygui.py", line 22, in <module>
    import dearpygui._dearpygui as internal_dpg
ImportError: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by lib/python3.9/site-packages/dearpygui/_dearpygui.so)

Any suggestions for fixing this?

Blobs as outputs

Hi all,

I keep getting just basic blobs/clouds of smoke as the output when I try and run some custom prompts. This is the prompt/config call I am using:

python3 main.py --text "a green monster truck" --workspace trial -O --guidance stable-diffusion --seed 12387651

I also tried without any seed parameter. Any ideas?

Thanks in advance!

"pip install ./raymarching" build fails

Anyone had a similar fail to build?
Clean Ubuntu 2204 with nvidia-470 drivers and base 22-4 cuda toolkit.

~/Downloads/stable-dreamfusion$ pip install ./raymarching
Processing ./raymarching
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: raymarching
  Building wheel for raymarching (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [92 lines of output]
      running bdist_wheel
      running build
      running build_ext
      /home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/utils/cpp_extension.py:813: UserWarning: The detected CUDA version (11.5) has a minor version mismatch with the version that was used to compile PyTorch (11.6). Most likely this shouldn't be a problem.
        warnings.warn(CUDA_MISMATCH_WARN.format(cuda_str_version, torch.version.cuda))
      /home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/utils/cpp_extension.py:820: UserWarning: There are no g++ version bounds defined for CUDA version 11.5
        warnings.warn(f'There are no {compiler_name} version bounds defined for CUDA version {cuda_str_version}')
      building '_raymarching' extension
      Emitting ninja build file /home/varoudis/Downloads/stable-dreamfusion/raymarching/build/temp.linux-x86_64-cpython-310/build.ninja...
      Compiling objects...
      Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
      [1/1] /usr/bin/nvcc  -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/TH -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/THC -I/home/varoudis/miniconda3/envs/pytorch01/include/python3.10 -c -c /home/varoudis/Downloads/stable-dreamfusion/raymarching/src/raymarching.cu -o /home/varoudis/Downloads/stable-dreamfusion/raymarching/build/temp.linux-x86_64-cpython-310/home/varoudis/Downloads/stable-dreamfusion/raymarching/src/raymarching.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -O3 -std=c++14 -U__CUDA_NO_HALF_OPERATORS__ -U__CUDA_NO_HALF_CONVERSIONS__ -U__CUDA_NO_HALF2_OPERATORS__ -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_raymarching -D_GLIBCXX_USE_CXX11_ABI=0
      FAILED: /home/varoudis/Downloads/stable-dreamfusion/raymarching/build/temp.linux-x86_64-cpython-310/home/varoudis/Downloads/stable-dreamfusion/raymarching/src/raymarching.o
      /usr/bin/nvcc  -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/TH -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/THC -I/home/varoudis/miniconda3/envs/pytorch01/include/python3.10 -c -c /home/varoudis/Downloads/stable-dreamfusion/raymarching/src/raymarching.cu -o /home/varoudis/Downloads/stable-dreamfusion/raymarching/build/temp.linux-x86_64-cpython-310/home/varoudis/Downloads/stable-dreamfusion/raymarching/src/raymarching.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -O3 -std=c++14 -U__CUDA_NO_HALF_OPERATORS__ -U__CUDA_NO_HALF_CONVERSIONS__ -U__CUDA_NO_HALF2_OPERATORS__ -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_raymarching -D_GLIBCXX_USE_CXX11_ABI=0
      /home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/c10/core/SymInt.h(84): warning #68-D: integer conversion resulted in a change of sign

      /home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/c10/core/SymInt.h(84): warning #68-D: integer conversion resulted in a change of sign

      /usr/include/c++/11/bits/std_function.h:435:145: error: parameter packs not expanded with ‘...’:
        435 |         function(_Functor&& __f)
            |                                                                                                                                                 ^
      /usr/include/c++/11/bits/std_function.h:435:145: note:         ‘_ArgTypes’
      /usr/include/c++/11/bits/std_function.h:530:146: error: parameter packs not expanded with ‘...’:
        530 |         operator=(_Functor&& __f)
            |                                                                                                                                                  ^
      /usr/include/c++/11/bits/std_function.h:530:146: note:         ‘_ArgTypes’
      ninja: build stopped: subcommand failed.
      Traceback (most recent call last):
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1808, in _run_ninja_build
          subprocess.run(
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/subprocess.py", line 524, in run
          raise CalledProcessError(retcode, process.args,
      subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

      The above exception was the direct cause of the following exception:

      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/home/varoudis/Downloads/stable-dreamfusion/raymarching/setup.py", line 44, in <module>
          setup(
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/__init__.py", line 87, in setup
          return distutils.core.setup(**attrs)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 973, in run_commands
          self.run_command(cmd)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 992, in run_command
          cmd_obj.run()
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/wheel/bdist_wheel.py", line 299, in run
          self.run_command('build')
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
          self.distribution.run_command(command)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 992, in run_command
          cmd_obj.run()
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/command/build.py", line 24, in run
          super().run()
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/command/build.py", line 132, in run
          self.run_command(cmd_name)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
          self.distribution.run_command(command)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 992, in run_command
          cmd_obj.run()
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 79, in run
          _build_ext.run(self)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
          self.build_extensions()
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 765, in build_extensions
          build_ext.build_extensions(self)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 466, in build_extensions
          self._build_extensions_serial()
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 492, in _build_extensions_serial
          self.build_extension(ext)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 202, in build_extension
          _build_ext.build_extension(self, ext)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 547, in build_extension
          objects = self.compiler.compile(
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 586, in unix_wrap_ninja_compile
          _write_ninja_file_and_compile_objects(
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1487, in _write_ninja_file_and_compile_objects
          _run_ninja_build(
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1824, in _run_ninja_build
          raise RuntimeError(message) from e
      RuntimeError: Error compiling objects for extension
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for raymarching
  Running setup.py clean for raymarching
Failed to build raymarching
Installing collected packages: raymarching
  Running setup.py install for raymarching ... error
  error: subprocess-exited-with-error

  × Running setup.py install for raymarching did not run successfully.
  │ exit code: 1
  ╰─> [105 lines of output]
      running install
      /home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_ext
      /home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/utils/cpp_extension.py:813: UserWarning: The detected CUDA version (11.5) has a minor version mismatch with the version that was used to compile PyTorch (11.6). Most likely this shouldn't be a problem.
        warnings.warn(CUDA_MISMATCH_WARN.format(cuda_str_version, torch.version.cuda))
      /home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/utils/cpp_extension.py:820: UserWarning: There are no g++ version bounds defined for CUDA version 11.5
        warnings.warn(f'There are no {compiler_name} version bounds defined for CUDA version {cuda_str_version}')
      building '_raymarching' extension
      creating /home/varoudis/Downloads/stable-dreamfusion/raymarching/build
      creating /home/varoudis/Downloads/stable-dreamfusion/raymarching/build/temp.linux-x86_64-cpython-310
      creating /home/varoudis/Downloads/stable-dreamfusion/raymarching/build/temp.linux-x86_64-cpython-310/home
      creating /home/varoudis/Downloads/stable-dreamfusion/raymarching/build/temp.linux-x86_64-cpython-310/home/varoudis
      creating /home/varoudis/Downloads/stable-dreamfusion/raymarching/build/temp.linux-x86_64-cpython-310/home/varoudis/Downloads
      creating /home/varoudis/Downloads/stable-dreamfusion/raymarching/build/temp.linux-x86_64-cpython-310/home/varoudis/Downloads/stable-dreamfusion
      creating /home/varoudis/Downloads/stable-dreamfusion/raymarching/build/temp.linux-x86_64-cpython-310/home/varoudis/Downloads/stable-dreamfusion/raymarching
      creating /home/varoudis/Downloads/stable-dreamfusion/raymarching/build/temp.linux-x86_64-cpython-310/home/varoudis/Downloads/stable-dreamfusion/raymarching/src
      Emitting ninja build file /home/varoudis/Downloads/stable-dreamfusion/raymarching/build/temp.linux-x86_64-cpython-310/build.ninja...
      Compiling objects...
      Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
      [1/2] c++ -MMD -MF /home/varoudis/Downloads/stable-dreamfusion/raymarching/build/temp.linux-x86_64-cpython-310/home/varoudis/Downloads/stable-dreamfusion/raymarching/src/bindings.o.d -pthread -B /home/varoudis/miniconda3/envs/pytorch01/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /home/varoudis/miniconda3/envs/pytorch01/include -fPIC -O2 -isystem /home/varoudis/miniconda3/envs/pytorch01/include -fPIC -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/TH -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/THC -I/home/varoudis/miniconda3/envs/pytorch01/include/python3.10 -c -c /home/varoudis/Downloads/stable-dreamfusion/raymarching/src/bindings.cpp -o /home/varoudis/Downloads/stable-dreamfusion/raymarching/build/temp.linux-x86_64-cpython-310/home/varoudis/Downloads/stable-dreamfusion/raymarching/src/bindings.o -O3 -std=c++14 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_raymarching -D_GLIBCXX_USE_CXX11_ABI=0
      [2/2] /usr/bin/nvcc  -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/TH -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/THC -I/home/varoudis/miniconda3/envs/pytorch01/include/python3.10 -c -c /home/varoudis/Downloads/stable-dreamfusion/raymarching/src/raymarching.cu -o /home/varoudis/Downloads/stable-dreamfusion/raymarching/build/temp.linux-x86_64-cpython-310/home/varoudis/Downloads/stable-dreamfusion/raymarching/src/raymarching.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -O3 -std=c++14 -U__CUDA_NO_HALF_OPERATORS__ -U__CUDA_NO_HALF_CONVERSIONS__ -U__CUDA_NO_HALF2_OPERATORS__ -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_raymarching -D_GLIBCXX_USE_CXX11_ABI=0
      FAILED: /home/varoudis/Downloads/stable-dreamfusion/raymarching/build/temp.linux-x86_64-cpython-310/home/varoudis/Downloads/stable-dreamfusion/raymarching/src/raymarching.o
      /usr/bin/nvcc  -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/TH -I/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/THC -I/home/varoudis/miniconda3/envs/pytorch01/include/python3.10 -c -c /home/varoudis/Downloads/stable-dreamfusion/raymarching/src/raymarching.cu -o /home/varoudis/Downloads/stable-dreamfusion/raymarching/build/temp.linux-x86_64-cpython-310/home/varoudis/Downloads/stable-dreamfusion/raymarching/src/raymarching.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -O3 -std=c++14 -U__CUDA_NO_HALF_OPERATORS__ -U__CUDA_NO_HALF_CONVERSIONS__ -U__CUDA_NO_HALF2_OPERATORS__ -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_raymarching -D_GLIBCXX_USE_CXX11_ABI=0
      /home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/c10/core/SymInt.h(84): warning #68-D: integer conversion resulted in a change of sign

      /home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/include/c10/core/SymInt.h(84): warning #68-D: integer conversion resulted in a change of sign

      /usr/include/c++/11/bits/std_function.h:435:145: error: parameter packs not expanded with ‘...’:
        435 |         function(_Functor&& __f)
            |                                                                                                                                                 ^
      /usr/include/c++/11/bits/std_function.h:435:145: note:         ‘_ArgTypes’
      /usr/include/c++/11/bits/std_function.h:530:146: error: parameter packs not expanded with ‘...’:
        530 |         operator=(_Functor&& __f)
            |                                                                                                                                                  ^
      /usr/include/c++/11/bits/std_function.h:530:146: note:         ‘_ArgTypes’
      ninja: build stopped: subcommand failed.
      Traceback (most recent call last):
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1808, in _run_ninja_build
          subprocess.run(
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/subprocess.py", line 524, in run
          raise CalledProcessError(retcode, process.args,
      subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

      The above exception was the direct cause of the following exception:

      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/home/varoudis/Downloads/stable-dreamfusion/raymarching/setup.py", line 44, in <module>
          setup(
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/__init__.py", line 87, in setup
          return distutils.core.setup(**attrs)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 973, in run_commands
          self.run_command(cmd)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 992, in run_command
          cmd_obj.run()
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/command/install.py", line 68, in run
          return orig.install.run(self)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/command/install.py", line 692, in run
          self.run_command('build')
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
          self.distribution.run_command(command)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 992, in run_command
          cmd_obj.run()
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/command/build.py", line 24, in run
          super().run()
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/command/build.py", line 132, in run
          self.run_command(cmd_name)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
          self.distribution.run_command(command)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 992, in run_command
          cmd_obj.run()
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 79, in run
          _build_ext.run(self)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
          self.build_extensions()
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 765, in build_extensions
          build_ext.build_extensions(self)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 466, in build_extensions
          self._build_extensions_serial()
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 492, in _build_extensions_serial
          self.build_extension(ext)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 202, in build_extension
          _build_ext.build_extension(self, ext)
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 547, in build_extension
          objects = self.compiler.compile(
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 586, in unix_wrap_ninja_compile
          _write_ninja_file_and_compile_objects(
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1487, in _write_ninja_file_and_compile_objects
          _run_ninja_build(
        File "/home/varoudis/miniconda3/envs/pytorch01/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1824, in _run_ninja_build
          raise RuntimeError(message) from e
      RuntimeError: Error compiling objects for extension
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> raymarching

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

(pytorch01) varoudis@varoudis-Standard-PC-i440FX-PIIX-1996:~/Downloads/stable-dreamfusion$ ninja --version
1.10.2.git.kitware.jobserver-1

(pytorch01) varoudis@varoudis-Standard-PC-i440FX-PIIX-1996:~/Downloads/stable-dreamfusion$ gcc --version
gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
(pytorch01) varoudis@varoudis-Standard-PC-i440FX-PIIX-1996:~/Downloads/stable-dreamfusion$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Thu_Nov_18_09:45:30_PST_2021
Cuda compilation tools, release 11.5, V11.5.119
Build cuda_11.5.r11.5/compiler.30672275_0

Gallery

  • a gummy jellyfish
df_ep0100_rgb.mp4
  • a koi fish
df_ep0100_rgb.mp4
  • a bread
df_ep0100_rgb.mp4
  • a delicious cake
df_ep0100_rgb.mp4
  • a DSLR photo of a yellow duck
ngp_ep0150_rgb.mp4
  • a rabbit, animated movie character, high detail 3d model
ngp_ep0100_rgb.mp4
  • a DSLR photo of a rose
ngp_ep0100_rgb.mp4
  • a high quality photo of a pineapple
ngp_ep0150_rgb.mp4
  • a DSLR photo of a hamburger
ngp_ep0150_rgb.mp4
  • a DSLR photo of cthulhu
ngp_ep0150_rgb.mp4

no module named cv2

Tried to install and run on mac and linux Ubuntu, both give this problem.
Screenshot 2022-10-21 at 11 51 02

save mesh does not work

hi,
i pulled the latest and when i click save mesh in the GUI it responds on powershell

stable-dreamfusion\nerf\gui.py", line 254, in callback_mesh
self.trainer.save_mesh(resolution=256, threshold=10)
TypeError: save_mesh() got an unexpected keyword argument 'threshold'

When i delete the threshold=10 in this func call, it runs and saves a mesh

Just getting blob

Here was my prompt:

a massive complex architectural megastructure, super detailed, many arches, negative space, gaps, capsules, tsutomo nihei, super horizontal, many holes and windows and domes, 8K HD

In the "oldschool" dreamfields, I get this:

https://www.instagram.com/p/CjURPkWrMvh/

Segmentation fault (core dumped) when running xatlas to unwrap UVs

Hey, Thanks for the nice repo :)

The training process works well on Python 3.9:

==> Start Test, save results to mytest/results
100% 100/100 [00:11<00:00,  8.40it/s]==> Finished Test.
100% 100/100 [00:13<00:00,  7.52it/s]
==> Saving mesh to mytest/mesh
[INFO] running xatlas to unwrap UVs for mesh: v=(126658, 3) f=(252036, 3)
Segmentation fault (core dumped)

but I met a issue when I was trying to do the test exp, which I can't get anything by using the xatlas to unwrap mesh.
The xatlas will crush for some unknown reason (Segmentation fault (core dumped)). To be more specfic, I find that it will crush on the Line 195-197 of the nerf/renderer.py;

            rast, _ = dr.rasterize(glctx, uv.unsqueeze(0), ft, (h, w)) # [1, h, w, 4]
            xyzs, _ = dr.interpolate(v.unsqueeze(0), rast, f) # [1, h, w, 3]
            mask, _ = dr.interpolate(torch.ones_like(v[:, :1]).unsqueeze(0), rast, f) # [1, h, w, 1]

I also try to solve it by changing the version of scikit-learn, cuda, torch, but all of them still can't solve that; Do you have any ideas? Thanks!

RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)

  • RTX 3090
  • CUDA 11.8
  • Ubuntu 22.04.1 LTS
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 520.61.05    Driver Version: 520.61.05    CUDA Version: 11.8     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  On   | 00000000:01:00.0  On |                  N/A |
| 44%   55C    P0   105W / 350W |   3234MiB / 24576MiB |     12%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      2358      G   /usr/lib/xorg/Xorg               2143MiB |
|    0   N/A  N/A      2714      G   /usr/bin/gnome-shell              239MiB |
|    0   N/A  N/A      4569      G   ...187800556795193677,131072      643MiB |
|    0   N/A  N/A      4892      G   ...AAAAAAAAA= --shared-files      108MiB |
+-----------------------------------------------------------------------------+
>>> torch.version.cuda
'11.7'
>>> torch.__version__
'1.13.0.dev20221006'

Input:

$ python main.py --text "a hamburger" --workspace trial -O

Output:

Namespace(text='a hamburger', O=True, O2=False, test=False, save_mesh=False, workspace='trial', guidance='stable-diffusion', seed=0, iters=15000, lr=0.001, ckpt='latest', cuda_ray=True, max_steps=1024, num_steps=256, upsample_steps=0, update_extra_interval=16, max_ray_batch=4096, albedo_iters=15000, bg_radius=1.4, density_thresh=10, fp16=True, backbone='grid', w=128, h=128, bound=1, dt_gamma=0, min_near=0.1, radius_range=[1.0, 1.5], fovy_range=[40, 70], dir_text=True, angle_overhead=30, angle_front=30, lambda_entropy=0.0001, lambda_orient=0.01, gui=False, W=800, H=800, radius=3, fovy=60, light_theta=60, light_phi=0, max_spp=1)
NeRFNetwork(
  (encoder): GridEncoder: input_dim=3 num_levels=16 level_dim=2 resolution=16 -> 2048 per_level_scale=1.3819 params=(6119864, 2) gridtype=tiled align_corners=False
  (sigma_net): MLP(
    (net): ModuleList(
      (0): Linear(in_features=32, out_features=64, bias=True)
      (1): Linear(in_features=64, out_features=64, bias=True)
      (2): Linear(in_features=64, out_features=4, bias=True)
    )
  )
  (encoder_bg): FreqEncoder: input_dim=2 degree=6 output_dim=26
  (bg_net): MLP(
    (net): ModuleList(
      (0): Linear(in_features=26, out_features=64, bias=True)
      (1): Linear(in_features=64, out_features=3, bias=True)
    )
  )
)
[INFO] successfully loaded hugging face user token!
[INFO] loading stable diffusion...
[INFO] loaded stable diffusion!
[INFO] Trainer: ngp | 2022-10-07_16-34-36 | cuda | fp16 | trial
[INFO] #parameters: 12248183
[INFO] Loading latest checkpoint ...
[WARN] No checkpoint found, model randomly initialized.
==> Start Training trial Epoch 1, lr=0.010000 ...
  0% 0/100 [00:00<?, ?it/s]Traceback (most recent call last):
  File "/home/genesst/Developer/stable-dreamfusion/main.py", line 144, in <module>
    trainer.train(train_loader, valid_loader, max_epoch)
  File "/home/genesst/Developer/stable-dreamfusion/nerf/utils.py", line 453, in train
    self.train_one_epoch(train_loader)
  File "/home/genesst/Developer/stable-dreamfusion/nerf/utils.py", line 673, in train_one_epoch
    pred_rgbs, pred_ws, loss = self.train_step(data)
  File "/home/genesst/Developer/stable-dreamfusion/nerf/utils.py", line 355, in train_step
    loss_guidance = self.guidance.train_step(text_z, pred_rgb)
  File "/home/genesst/Developer/stable-dreamfusion/nerf/sd.py", line 97, in train_step
    w = (1 - self.scheduler.alphas_cumprod[t]).to(self.device)
RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)
  0% 0/100 [00:00<?, ?it/s]

How can I fix this?

training in latent space

Have you noticed that the latent space is actually just a 4x4 image representation of the same image, each of these small images are 16x16 pixel size? And this is layered into 4 channels. So in that sense we actually have 64 channels of 16x16 size images.
So in that sense we can think of the latent space as a 16x16x64 representation of the original 512x512x3 image.

If that's the case, then the original optimisation should work for this 3D training.

I hope I'm right and you can use this idea.

Is it possible to run it on a M1 Mac?

Since it uses stable diffusion in the background i wonder if it is possible to run dreamfusion on a M1 Mac, considering there are M1 stable diffusion versions like the bfirsh branch linked bellow.

https://github.com/bfirsh/stable-diffusion

I tried running dreamfusion on a M1 Macbook Pro. The installation process didn't result in any errors, but it fails at the installing of the extension models on the first time running. It results in the following CUDA error (already discussed in the issues):

OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.

Since it is not possible to install the CUDA toolkit on a M1 Mac, is there a way to bypass this problem?

Colab Problem

I get the following error when I do "start trainig" even though I've given it my hugging face login. Am I doing something wrong?

Namespace(H=800, O=True, O2=False, W=800, albedo_iters=15000, angle_front=30, angle_overhead=30, backbone='grid', bg_radius=1.4, bound=1, ckpt='scratch', cuda_ray=True, density_thresh=10, dir_text=True, dt_gamma=0, eval_interval=10, fovy=60, fovy_range=[40, 70], fp16=True, gui=False, guidance='stable-diffusion', h=64, iters=5000, lambda_entropy=0.0001, lambda_orient=0.01, light_phi=0, light_theta=60, lr=0.001, max_ray_batch=4096, max_spp=1, max_steps=1024, min_near=0.1, num_steps=128, radius=3, radius_range=[1.0, 1.5], save_mesh=True, seed=0, test=False, text='a DSLR photo of a pineapple', update_extra_interval=16, upsample_steps=0, w=64, workspace='trial')
NeRFNetwork(
  (encoder): GridEncoder: input_dim=3 num_levels=16 level_dim=2 resolution=16 -> 2048 per_level_scale=1.3819 params=(6119864, 2) gridtype=tiled align_corners=False
  (sigma_net): MLP(
    (net): ModuleList(
      (0): Linear(in_features=32, out_features=64, bias=True)
      (1): Linear(in_features=64, out_features=64, bias=True)
      (2): Linear(in_features=64, out_features=4, bias=True)
    )
  )
  (encoder_bg): FreqEncoder: input_dim=2 degree=6 output_dim=26
  (bg_net): MLP(
    (net): ModuleList(
      (0): Linear(in_features=26, out_features=64, bias=True)
      (1): Linear(in_features=64, out_features=3, bias=True)
    )
  )
)
[INFO] successfully loaded hugging face user token!
[INFO] loading stable diffusion...
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
[/usr/local/lib/python3.7/dist-packages/huggingface_hub/utils/_errors.py](https://localhost:8080/#) in hf_raise_for_status(response, endpoint_name)
    212     try:
--> 213         response.raise_for_status()
    214     except HTTPError as e:

7 frames
HTTPError: 403 Client Error: Forbidden for url: https://huggingface.co/CompVis/stable-diffusion-v1-4/resolve/main/vae/diffusion_pytorch_model.bin

The above exception was the direct cause of the following exception:

HfHubHTTPError                            Traceback (most recent call last)
HfHubHTTPError: <class 'requests.exceptions.HTTPError'> (Request ID: Dk1dugtFYnhavLD2yWsHj)

During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)
[/usr/local/lib/python3.7/dist-packages/diffusers/modeling_utils.py](https://localhost:8080/#) in from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
    354             except HTTPError as err:
    355                 raise EnvironmentError(
--> 356                     "There was a specific connection error when trying to load"
    357                     f" {pretrained_model_name_or_path}:\n{err}"
    358                 )

OSError: There was a specific connection error when trying to load CompVis/stable-diffusion-v1-4:
<class 'requests.exceptions.HTTPError'> (Request ID: Dk1dugtFYnhavLD2yWsHj)

NEWB help for install

On my E: root:
git clone https://github.com/ashawkey/stable-dreamfusion.git

Edited TOKEN, just a text file, no extension, with my token number in it

Then ran:
python main.py --text "a hamburger" --workspace trial -O

Got:
Traceback (most recent call last):
File "E:\stable-dreamfusion\main.py", line 4, in
from nerf.provider import NeRFDataset
File "E:\stable-dreamfusion\nerf\provider.py", line 2, in
import cv2
ModuleNotFoundError: No module named 'cv2'

Is this a PATH issue or am I missing some file or??

Not getting anything meaningful

I tried the following command

# test (exporting 360 video, and an obj mesh with png texture)
python main_nerf.py --text "a hamburger" --workspace trial -O --test

and got nothing meaningful. I got an output video that basically looked like inside of an empty sphere. I tried other prompts and still the same issue. Am I missing something, or is it an example of "bad failures" as mentioned in the readme?

Detailed Windows Install Guide?

Hello. I'm an old fart trying to learn new tricks. I have the CUDA toolkit installed, also have Miniconda, and Python 3.10. I have spent 3 hours switching between Conda and pip trying to get this and all it's dependencies up and running, to no avail.

Would some galaxy brain who has this running under Windows 10 be willing to write a detailed guide, with screenshots, for us lowly end users? Maybe even a FAQ with common install issues under Windows.

I am DYING to create 3D objects, especially using SD! I have several flavors of SD UIs up and running, and the ability to create with text...AMAZING.

I want to be able to mess with text2video, and create 3 objects. I have plans people, plans.

Thank you to anyone who can do this, and I will help in any way I can.

Also, are there discussions? A Discord?

No CUDA runtime found

Hello-
I'm trying to install on a windows machine. CUDA 11.8 is installed, but getting persistent error of

No CUDA runtime is found, using CUDA_HOME='C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8' running install
while installing raymarching. Any ideas on where to begin?

Better method to append view information

If I understand correctly, the code currently append the view information at the end of the text prompt which is generally not good from my experience. Instead, I append it at the beginning like this "overhead view of a squirrel playing piano".

This is the result with the prompt "a squirrel playing piano, overhead view"


This is the result with the prompt "overhead view of a squirrel playing piano"

SDS loss

According to section 2 in the paper, epshat = pred_noise_text + guidance_scale * (pred_noise_text - pred_noise_uncond).
While it seems that in the implementation in sd.py, it's assigned as: epshat = pred_noise_uncond + guidance_scale * (pred_noise_text - pred_noise_uncond).
Is this intentional?

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.