Giter VIP home page Giter VIP logo

Comments (5)

nikhilaravi avatar nikhilaravi commented on July 17, 2024 1

@michele-arrival this is not because of the blend params but the rasterization settings. Currently your values are:

raster_settings = RasterizationSettings(
    image_size=frame_size,
    blur_radius=np.log(1.0 / 1e-4 - 1.0) * blend_params.sigma,
    faces_per_pixel=2,
    bin_size=1
)

There are two implementations of rasterization in pytorch3d and the approach that is used is determined by the value of the bin_size setting.

The first naive approach (when bin_size = 0) loops through all the faces in the mesh for each pixel. The second approach (when bin_size > 0) involves two steps the first of which is a coarse step where the image is split into a rough grid (or bins) and each face in the mesh is assigned to a grid cell (or bin). The second step loops through each pixel and only looks at the faces in the bin in which the pixel lies. Refer to the docs on the renderer for more details on this 'coarse-to-fine' approach: https://pytorch3d.org/docs/renderer. Also refer to the PyTorch3D API docs for the rasterizer here

For coarse-to-fine rasterization the bin_size setting determines the number of bins and in this case you have set it to 1. There is an upper bound on the number of faces which can be allocated to each bin and as the error mentions Got 256; that's too many! (for reference with, the error is from RasterizeMeshesCoarseCuda to help you debug such issues in future).

If you want to enable the coarse-to-fine rasterization you can just leave the bin_size empty and it will be set based on heuristics. If you want to use the naive rasterization approach you can set bin_size = 0.

from pytorch3d.

cosw0t avatar cosw0t commented on July 17, 2024 1

Yes sorry of course I meant RasterizationSettings.

Thanks for the explanation, I understand now.
I guess a clearer error message wouldn't be too bad though. For one thing it looks like a low level exception, not a user error, even thought it is. Also It's not immediately clear what *that* in that's too many is.

As a side note, when the image is big (> 1024) leaving bin_size out of the settings means another kind of exception incompatible function arguments later on.
see here where bin_size remains None:

if bin_size is None:
if not verts_packed.is_cuda:
# Binned CPU rasterization is not supported.
bin_size = 0
else:
# TODO better heuristics for bin size.
if image_size <= 64:
bin_size = 8
elif image_size <= 256:
bin_size = 16
elif image_size <= 512:
bin_size = 32
elif image_size <= 1024:
bin_size = 64
if max_faces_per_bin is None:
max_faces_per_bin = int(max(10000, verts_packed.shape[0] / 5))
return _RasterizeFaceVerts.apply(
face_verts,
mesh_to_face_first_idx,
num_faces_per_mesh,
image_size,
blur_radius,
faces_per_pixel,
bin_size,
max_faces_per_bin,
perspective_correct,
)

Cheers!

from pytorch3d.

nikhilaravi avatar nikhilaravi commented on July 17, 2024

@michele-arrival, yes we could definitely make the error message clearer. Thanks for pointing out the error for when image size is > 1024. We assumed that most use cases involving batched rendering of meshes would require image sizes < 1024, but we can fix this so that rendering is enabled with any image size. Feel free to submit a PR if you would like to try and fix this yourself!

from pytorch3d.

cosw0t avatar cosw0t commented on July 17, 2024

#90

from pytorch3d.

nikhilaravi avatar nikhilaravi commented on July 17, 2024

@michele-arrival your PR has been merged so I am closing this issue.

from pytorch3d.

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.