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

Backbones #14

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open

Backbones #14

wants to merge 27 commits into from

Conversation

humanpose1
Copy link
Collaborator

I open the pr but it is not over yet.
I added the code for KPConv and Pointnet++. But I haven't tested the integration yet. I also need to add the tests
I modified the class PointCloudDataModule We need to adapt to the dense(pointnet) partial dense(kpconv) and sparse (sparse conv 3d) format. So I also modified the conf to add the conv format.

Tell me what you think.

@humanpose1 humanpose1 requested a review from CCInc August 5, 2021 09:28
@@ -31,3 +25,10 @@ def test_forward(self):
data = Batch(pos=pos, x=x, batch=batch, y=y, coords=coords)
model.set_input(data)
model.forward()


@pytest.mark.slow
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not perfect but it allows testing one epoch to see if the command is working. We can deactivate this test using the k command. maybe for each dataset, we should add a max sample variable.

 python -m pytest test -k "not slow"

It will be useful when we'll want to perform tests only locally.

Copy link
Member

@CCInc CCInc Aug 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pytorch lightning does a "validation" run at the beginning of the training for 2 batches to make sure the model works, I wonder if there's a way we can just do that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@CCInc CCInc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how much separation we have between the backbones and the models. I wonder if we can even change "applications" to be named "backbones". Did you find it was easy to implement new backbones with the code structure? Or can we improve the modularity somehow?

Eventually I would like to redo the application model files. I think that's the messiest part of our code right now. And there's a lot of duplicated code between the models.

Do people actually use the application configs (encoder_....yaml, unet_....yaml)? I wonder if we can remove those and remove some of the Factory code, since I think most people will be using the backbone as part of a larger model. Also, the backbone config is already defined in the conf/model folder, so they can use it from those files if they need.

We could further separate the model config from the backbone config to make it easier for that use case.

I left some general comments but I know you're still working so feel free to ignore those until you're finished!

]
max_num_neighbors:
[[max_neighbors,max_neighbors], [max_neighbors, max_neighbors], [max_neighbors, max_neighbors], [max_neighbors, max_neighbors], [max_neighbors, max_neighbors]]
module_name: KPDualBlock
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we can redo this to use hydra instantiation for blocks and remove some of the model factory reflection code

@@ -0,0 +1,342 @@
#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file used for anything?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to answer this. This is useful in kernel_utils.py. before running kpconv, kpconv need to compute the kernel points, it use an optimization process to compute the kernel point (see section B of supplementary material of the original article). Then it saves the files locally using function of plyutils. We can replace it by the library plyfile.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds good, we can remember to add it to the requirements.txt

log = logging.getLogger(__name__)


def PointNet2(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we should try to clean up these ModelFactory files, I think they are very messy and have a lot of duplication

torch_points3d/data/batch.py Show resolved Hide resolved
torch_points3d/datasets/base_dataset.py Outdated Show resolved Hide resolved
def _get_collate_function(conv_type: str, is_multiscale: bool, pre_collate_transform: Optional[Callable] = None):
is_dense: bool = ConvolutionFormatFactory.check_is_dense_format(conv_type)
if is_multiscale:
if conv_type.lower() == ConvolutionFormat.PARTIAL_DENSE.value.lower():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, can we do validation on "conv_type" so that the value is always matching the enum? Maybe once we do static checking with hydra it will do that for us

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to perform static type checking on conv_type. But here we are not doing type checking.

torch_points3d/utils/config.py Outdated Show resolved Hide resolved
@humanpose1
Copy link
Collaborator Author

Thanks for the feedbacks,

For the modules, There are a lot of repetitions and it is the mess, but also reproducibility matters. If we start modifying modules, we have to be sure that it works and we can reproduce the results of the published paper of tp3d.

Adding these two models was complicated because the data structure (SimpleBatch and Batch) between pointnet and kpconv is different. And we need to integrate multiscale transform. but you're right. I think we can be better in the modularity.

you're right. the conf file in applications is confusing: This issue. shows it. But being able to create easily a backbone without giving any conf file or yaml is interesting. As in this repo, it is interesting to have hardcoded backbones (and models ?).

I agree, we can call the directory backbones.
I will let applications/conf for now because It is handier for the tests but You're right. in the future, we'll have to remove it and use those of conf/models.

Ok I will propose something else for the ModelFactory and the KPConvDualBlock using hydra instantiation.

@CCInc
Copy link
Member

CCInc commented Aug 5, 2021

I think worrying about reproducibility as far as the paper goes is not as much as a concern, as we can just point to the 1.x branch if they want exact reproducibility. Many of the released source code for DL do not match the paper results directly.

Let me know if I can help in making it more modular, which parts do you think are lacking?

Actually, I think once we have dataclasses for hydra we will be able to set default values and initialize with those default dataclasses, for testing purposes. Or maybe seperating the backbone config from the model is enough.

@humanpose1
Copy link
Collaborator Author

I mean if it is not too far from the paper it is ok. But it would be cumbersome that the results are too far. I experienced that for some models, little details change and the model does not converge anymore as expected for some dataset.

the multiscale transform with the set_strategy is not a bad idea for kpconv, it allows trying many combinations of samplers and neighbors search. but I wonder if it could also be applied to pointnet++ (the sampler would be a fps and neighborhood search would be radius search).
with a general model, we could also write easily RandLANet(Randlanet's original source code have a lot of code taken from kpconv).
the difficulty is that pointnet++ batch and kpconv batch are different.

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

Successfully merging this pull request may close these issues.

2 participants