Giter Site home page Giter Site logo

Comments (10)

Speierers avatar Speierers commented on August 16, 2024 1

First of all, you are using mitsuba.set_variant('gpu_autodiff_spectral'), meaning that red.reflectance.values is not a Color3f here but a set of values (see regular.cpp).

Could you try again with gpu_autodiff_rgb (and use ``red.reflectance.value` then)?

from mitsuba2.

Speierers avatar Speierers commented on August 16, 2024 1

I should work with spectral rendering. You will need to provide spectral values instead of RGB here tho.

from mitsuba2.

Speierers avatar Speierers commented on August 16, 2024

Thanks for reporting this!
It should now be fixed (d066893).

from mitsuba2.

alexus37 avatar alexus37 commented on August 16, 2024

Wow, thanks for the quick fix! Love the spirit!

from mitsuba2.

garethwalkom avatar garethwalkom commented on August 16, 2024

I'm getting a similar error when using the example at https://mitsuba2.readthedocs.io/en/latest/src/inverse_rendering/pytorch.html:

>>> import enoki as ek
>>> import mitsuba
>>> mitsuba.set_variant('gpu_autodiff_spectral')
>>>
>>> from mitsuba.core import Thread, Vector3f
>>> from mitsuba.core.xml import load_file
>>> from mitsuba.python.util import traverse
>>> from mitsuba.python.autodiff import render_torch, write_bitmap
>>> import torch
>>> import time
>>>
>>> Thread.thread().file_resolver().append('cbox')
>>> scene = load_file('../resources/data/scenes/cbox/cbox.xml')
2020-04-02 00:34:07 INFO  main  [xml.cpp:1129] Loading XML file "..\resources\data\scenes\cbox\cbox.xml" ..
2020-04-02 00:34:07 INFO  main  [xml.cpp:1130] Using variant "gpu_autodiff_spectral"
2020-04-02 00:34:07 INFO  main  [PluginManager] Loading plugin "plugins\regular.dll" ..
2020-04-02 00:34:07 INFO  main  [PluginManager] Loading plugin "plugins\path.dll" ..
2020-04-02 00:34:07 INFO  main  [PluginManager] Loading plugin "plugins\independent.dll" ..
2020-04-02 00:34:07 INFO  main  [PluginManager] Loading plugin "plugins\gaussian.dll" ..
2020-04-02 00:34:07 INFO  main  [PluginManager] Loading plugin "plugins\hdrfilm.dll" ..
2020-04-02 00:34:07 INFO  main  [PluginManager] Loading plugin "plugins\perspective.dll" ..
2020-04-02 00:34:07 INFO  main  [PluginManager] Loading plugin "plugins\diffuse.dll" ..
2020-04-02 00:34:07 INFO  main  [PluginManager] Loading plugin "plugins\area.dll" ..
2020-04-02 00:34:07 INFO  main  [PluginManager] Loading plugin "plugins\d65.dll" ..
2020-04-02 00:34:07 INFO  main  [PluginManager] Loading plugin "plugins\obj.dll" ..
2020-04-02 00:34:07 INFO  main  [Scene] Validating and building scene in OptiX.
>>> params = traverse(scene)
>>> params.keep(['red.reflectance.value'])
>>> param_ref = params['red.reflectance.value'].torch()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\u0120819\mitsuba2\dist\python\mitsuba\python\util.py", line 41, in __getitem__
    return self.get_property(*(self.properties[key]))
KeyError: 'red.reflectance.value'
>>> print(params)
ParameterMap[
]

I also haven't changed anything from the example scene cbox.xml.

I'm unsure how to fix this, but I have pulled and built the gpu_autodiff_spectral variant with the latest mitsuba2 release.

from mitsuba2.

Speierers avatar Speierers commented on August 16, 2024

This should be fixed now: bffd685
Thanks!

Also is should be

params.keep(['red.reflectance.values'])

as you are in spectral mode.

from mitsuba2.

garethwalkom avatar garethwalkom commented on August 16, 2024

@Speierers thanks! That did the job.

Also is should be

params.keep(['red.reflectance.values'])
as you are in spectral mode.

Is the above included in the documentation? I couldn't see it when following https://mitsuba2.readthedocs.io/en/latest/src/inverse_rendering/pytorch.html

A few lines down, I now have the following error:

>>> param_ref = params['red.reflectance.values'].torch()
>>> print(param_ref)
tensor([0.0400, 0.0460, 0.0480, 0.0530, 0.0490, 0.0500, 0.0530, 0.0550, 0.0570,
        0.0560, 0.0590, 0.0570, 0.0610, 0.0610, 0.0600, 0.0620, 0.0620, 0.0620,
        0.0610, 0.0620, 0.0600, 0.0590, 0.0570, 0.0580, 0.0580, 0.0580, 0.0560,
        0.0550, 0.0560, 0.0590, 0.0570, 0.0550, 0.0590, 0.0590, 0.0580, 0.0590,
        0.0610, 0.0610, 0.0630, 0.0630, 0.0670, 0.0680, 0.0720, 0.0800, 0.0900,
        0.0990, 0.1240, 0.1540, 0.1920, 0.2550, 0.2870, 0.3490, 0.4020, 0.4430,
        0.4870, 0.5130, 0.5580, 0.5840, 0.6200, 0.6060, 0.6090, 0.6510, 0.6120,
        0.6100, 0.6500, 0.6380, 0.6270, 0.6200, 0.6300, 0.6280, 0.6420, 0.6390,
        0.6570, 0.6390, 0.6350, 0.6420], device='cuda:0')
>>> image_ref = render_torch(scene, spp=8)
>>> crop_size = scene.sensors()[0].film().crop_size()
>>> write_bitmap('out.png', image_ref, crop_size)
>>> params['red.reflectance.values'] = [.9, .9, .9]
>>> params.update()
>>> params_torch = params.torch()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\u0120819\mitsuba2\dist\python\mitsuba\python\util.py", line 95, in torch
    return {k: v.torch().requires_grad_() for k, v in self.items()}
  File "C:\Users\u0120819\mitsuba2\dist\python\mitsuba\python\util.py", line 95, in <dictcomp>
    return {k: v.torch().requires_grad_() for k, v in self.items()}
AttributeError: 'float' object has no attribute 'torch'

Thanks.

from mitsuba2.

merlinND avatar merlinND commented on August 16, 2024

Also I think that on this line, you might need to use an Enoki type rather than a raw list?

params['red.reflectance.values'] = [.9, .9, .9]

from mitsuba2.

Speierers avatar Speierers commented on August 16, 2024

Also I think that on this line, you might need to use an Enoki type rather than a raw list?

params['red.reflectance.values'] = [.9, .9, .9]

Not sure about this. This is how it is done in the tuto. I think the implicit cast can figure it out.

from mitsuba2.

garethwalkom avatar garethwalkom commented on August 16, 2024

Could you try again with gpu_autodiff_rgb (and use ``red.reflectance.value` then)?

This worked, thank you! Pretty cool. Does it not work with spectral rendering?

from mitsuba2.

Related Issues (20)

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.