Skip to content

Commit 533887a

Browse files
bottlerfacebook-github-bot
authored andcommitted
remove dataclass for python 3.6 compatibility.
Summary: Make RasterizationSettings be a NamedTuple instead of a dataclass. This makes the mesh renderer work with python 3.6. Reviewed By: nikhilaravi Differential Revision: D19769924 fbshipit-source-id: db839f3506dda7d3344fb8a101fa75bdf139ce39
1 parent 3c9f065 commit 533887a

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

pytorch3d/renderer/mesh/rasterizer.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/usr/bin/env python3
22
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
33

4-
5-
from dataclasses import dataclass
64
from typing import NamedTuple, Optional
75
import torch
86
import torch.nn as nn
@@ -20,14 +18,31 @@ class Fragments(NamedTuple):
2018

2119

2220
# Class to store the mesh rasterization params with defaults
23-
@dataclass
2421
class RasterizationSettings:
25-
image_size: int = 256
26-
blur_radius: float = 0.0
27-
faces_per_pixel: int = 1
28-
bin_size: Optional[int] = None
29-
max_faces_per_bin: Optional[int] = None
30-
perspective_correct: bool = False
22+
__slots__ = [
23+
"image_size",
24+
"blur_radius",
25+
"faces_per_pixel",
26+
"bin_size",
27+
"max_faces_per_bin",
28+
"perspective_correct",
29+
]
30+
31+
def __init__(
32+
self,
33+
image_size: int = 256,
34+
blur_radius: float = 0.0,
35+
faces_per_pixel: int = 1,
36+
bin_size: Optional[int] = None,
37+
max_faces_per_bin: Optional[int] = None,
38+
perspective_correct: bool = False,
39+
):
40+
self.image_size = image_size
41+
self.blur_radius = blur_radius
42+
self.faces_per_pixel = faces_per_pixel
43+
self.bin_size = bin_size
44+
self.max_faces_per_bin = max_faces_per_bin
45+
self.perspective_correct = perspective_correct
3146

3247

3348
class MeshRasterizer(nn.Module):

0 commit comments

Comments
 (0)