Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error in the Tree3DMix2 code #2

Open
zqalex opened this issue May 6, 2024 · 1 comment
Open

An error in the Tree3DMix2 code #2

zqalex opened this issue May 6, 2024 · 1 comment

Comments

@zqalex
Copy link

zqalex commented May 6, 2024

In PointCloudSegmentation/torch_points3d/core/data_transform/transforms.py, there is:

class Tree3DMix2(object):
"""
Tree3DMix2 prevents tree instances from overlapping
"""

def __init__(self):
    pass

def __call__(self, data, data2, stuff_classes):

However, when running the above code, the Compose.py calls transform with only one input "data", and does not provide data2 and stuff_classes, resulting in an error. How can this issue be resolved?

File "/ForAINet-main/PointCloudSegmentation/torch_points3d/datasets/panoptic/treeins_set1.py", line 512, in getitem
data = super().getitem(idx)
File "site-packages/torch_geometric/data/dataset.py", line 194, in getitem
data = data if self.transform is None else self.transform(data)
File "site-packages/torch_geometric/transforms/compose.py", line 15, in call
data = transform(data)
TypeError: call() missing 2 required positional arguments: 'data2' and 'stuff_classes'

@bxiang233
Copy link
Collaborator

bxiang233 commented May 13, 2024

In PointCloudSegmentation/torch_points3d/core/data_transform/transforms.py, there is:

class Tree3DMix2(object): """ Tree3DMix2 prevents tree instances from overlapping """

def __init__(self):
    pass

def __call__(self, data, data2, stuff_classes):

However, when running the above code, the Compose.py calls transform with only one input "data", and does not provide data2 and stuff_classes, resulting in an error. How can this issue be resolved?

File "/ForAINet-main/PointCloudSegmentation/torch_points3d/datasets/panoptic/treeins_set1.py", line 512, in getitem data = super().getitem(idx) File "site-packages/torch_geometric/data/dataset.py", line 194, in getitem data = data if self.transform is None else self.transform(data) File "site-packages/torch_geometric/transforms/compose.py", line 15, in call data = transform(data) TypeError: call() missing 2 required positional arguments: 'data2' and 'stuff_classes'

Hi, thanks for remind me of this error!

please modify (For me it is on Line 178) in file
#YOUR_CONDA_LOCATION#/envs/#YOUR_ENV_NAME#/lib/python3.8/site-packages/torch_geometric/data/dataset.py

to:

def __getitem__(
    self,
    idx: Union[int, np.integer, IndexType],
) -> Union['Dataset', Data]:
    r"""In case :obj:`idx` is of type integer, will return the data object
    at index :obj:`idx` (and transforms it in case :obj:`transform` is
    present).
    In case :obj:`idx` is a slicing object, *e.g.*, :obj:`[2:5]`, a list, a
    tuple, a PyTorch :obj:`LongTensor` or a :obj:`BoolTensor`, or a numpy
    :obj:`np.array`, will return a subset of the dataset at the specified
    indices."""
    if (isinstance(idx, (int, np.integer))
            or (isinstance(idx, Tensor) and idx.dim() == 0)
            or (isinstance(idx, np.ndarray) and np.isscalar(idx))):

        data = self.get(self.indices()[idx])
        #data = data if self.transform is None else self.transform(data)
        for transform in self.transform.transforms:
            if transform.__repr__() == "Mix3D":
                data2 = self.get(self.indices()[idx])
                data = transform(data, data2)
            elif transform.__repr__() == "Tree3DMix":
                data2 = self.get(self.indices()[idx])
                data = transform(data, data2, self.stuff_classes)
            else:
                data = transform(data)
        return data

    else:
        return self.index_select(idx)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants