Skip to content

Added model, training and data preparation features - #149

Merged
DaliCHEBBI merged 22 commits into
mainfrom
feature_mac
Oct 29, 2026
Merged

DaliCHEBBI merged 22 commits into
mainfrom
feature_mac

Conversation

@DaliCHEBBI

Copy link
Copy Markdown
Collaborator

MR: added model, training and data preparation features

@leavauchier leavauchier changed the title Feature mac Added model, training and data preparation features Sep 24, 2026
Comment thread myria3d/models/losses/combined.py Resolved
Comment thread myria3d/models/losses/focal.py Resolved
Comment thread myria3d/models/losses/lovasz.py Resolved
Comment thread myria3d/_version.py Resolved
Comment thread myria3d/pctl/dataset/toy_dataset.py Resolved
Comment thread tests/myria3d/test_train_and_predict.py Resolved
Comment thread tests/test_run.py Resolved
Comment thread tests/test_run.py Resolved
Comment thread myria3d/models/losses/lovasz.py Resolved
Comment thread myria3d/_version.py Resolved
Comment thread tests/test_run.py Resolved
Comment thread tests/test_run.py Resolved
Comment on lines +8 to +56

# Check that using the new version of the code returns
# the same model structure with the default parameters as the older version
def test_pyg_randlanet_model_structure():
num_features = 9
num_classes = 6
decimation = 4
num_neighbors = 16

model1 = PyGRandLANet(
num_features,
num_classes,
decimation=decimation,
num_neighbors=num_neighbors,
)

model2 = PyGRandLANet(
num_features,
num_classes,
decimation=decimation,
num_neighbors=num_neighbors,
dims=[32, 128, 256, 512],
)

# The default dims are (32, 128, 256, 512), so passing them explicitly must
# yield the same per-block input/output channel dimensions.
for block_name in ("block1", "block2", "block3", "block4"):
block1 = getattr(model1, block_name)
block2 = getattr(model2, block_name)
assert block1.d_in == block2.d_in
assert block1.d_out == block2.d_out

# The first linear layer (fc0) maps features to the bottleneck dimension.
assert model1.fc0.in_features == model2.fc0.in_features
assert model1.fc0.out_features == model2.fc0.out_features

# Explicitly check the expected default embedding dimensions.
assert model1.block1.d_out == 32
assert model1.block2.d_out == 128
assert model1.block3.d_out == 256
assert model1.block4.d_out == 512

# model2
assert model2.block1.d_out == 32
assert model2.block2.d_out == 128
assert model2.block3.d_out == 256
assert model2.block4.d_out == 512


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nitpick: not sure this is interesting to keep this check on both models (one is enough as you mentioned that checking that the older version still works is done with test_run_predict)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I ll remove it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

both Fractal model and LargeDataset_100K_... will be embedded in the docker image, it does not seem very heavy compared to the Docker image weight, but is it what you meant?

@DaliCHEBBI DaliCHEBBI Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The models can be embedded in the docker image with some caveats. If the model changes (without changing the code) , regenerating the docker image is compulsory if we want to update the model. I have actually some concerns about the docker instance size ( 2 go or higher) as the patch size is now larger for the new model.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yep, this github repo does not intend to store trained model (public models should rather be published to hugging face), but the previously embedded model is here to provide an example and let people try myria3d without having to train a model on their own
Same concerns about the patch size (we'd need to experiment on that)

Comment thread tests/test_run.py Outdated
)

# DICT of batch size given subtile_width for externalized-embeddings model.
# Adjust these to match your externalized-embeddings assets.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

pas sûre de comprendre l'intérêt de ce dict, l'info est pas dans le yaml ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

oui l'info est dans le yaml, j'ai modifié pour lire directement depuis le config file

@@ -4,14 +4,48 @@
import os.path as osp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pour tester la possibilité de changer le batch size et vérifier que ça marche bien, est-ce que ça te parait pertinent de faire un 2e toy dataset avec une autre taille de subtile ? (dans l'absolu ça pourrait même être n'importe quoi d'autre que 50 ou 100)

Comment thread tests/test_run.py Outdated
f"--config-name={EXTERNAL_EMBEDDINGS_CONFIG_NAME}",
"+model.neural_net_hparams.dims=[48,192,384,768]",
f"--config-name={config_file.stem}", # config file name without the ".yaml" extension
#"+model.neural_net_hparams.dims=[48,192,384,768]", # dims in yaml config file, so no need to override here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

commented code to remove

Comment thread tests/test_run.py Resolved
Comment thread tests/test_run.py Resolved
Comment thread tests/test_run.py
for ckpt_file in Path(EXTERNAL_EMBEDDINGS_CONFIG_DIR).glob("*.ckpt"):
# try to find yaml with ckpt prefix and -inference-Myria3DV*.yaml suffix using glob
config_file = list(Path(EXTERNAL_EMBEDDINGS_CONFIG_DIR).glob(ckpt_file.stem + "-inference-Myria3DV*.yaml"))
if config_file:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sorry I forgot something: it would be better to raise an error when a ckpt file does not have a matching yaml file to prevent silently not running tests on checkpoints from trained_assets

leavauchier
leavauchier previously approved these changes Oct 29, 2026
leavauchier
leavauchier previously approved these changes Oct 29, 2026
@DaliCHEBBI
DaliCHEBBI merged commit 3ba98d2 into main Oct 29, 2026
6 checks passed
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