Skip to content

Conversation

@deruyter92
Copy link
Collaborator

@deruyter92 deruyter92 commented Feb 9, 2026

This PR proposes 2 changes to the repository:

1. Add configuration groups as dataclasses:
Instead of a long list of arguments that are introduced via argparse, I added configuration dataclasses that represent subgroups of configurations. There are many advantages of using dataclasses. For instance, since some modules require only a subset of arguments, it makes sense to separate these. Also dataclasses are much more easier to validate and configure with custom default parameters, they can be read / saved into yaml files, etc.

Note: for now the configs are implemented in parallel to the existing args. I would advise you to replace all occurrences in the code that now uses arg.namespace with the corresponding config dataclass: e.g. args.myfield -> config.myfield where config is an instance of only the corresponding config that is required for that particular module e.g. ModelConfig for the model.

2. Add a model registry instead of loading from module files
Instead of loading from a file specified in arg.model_path, it would be better to have a modularly extendable registry of models. You only have to choose which of the models from the registry you want to use.

Note: in my last commit I made the replacement in all affected files. You can choose to drop this comment if you want to keep the registry only in parallel to your own implementation for now.

EDIT: I only added an example registry usage for the human pose model now. Please check for animal model as well.

@xiu-cs, let me know what you think!

- New ABC base_model as template.
- Easy access to defined set of models.
- Modularly extendable with new implementations.
@xiu-cs xiu-cs requested review from Copilot and xiu-cs February 9, 2026 14:26
@deruyter92 deruyter92 marked this pull request as draft February 9, 2026 14:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a structured configuration system (grouped dataclass configs) and replaces ad-hoc model loading-by-filepath with a model registry selected via --model_type, updating training/testing/demo entrypoints accordingly.

Changes:

  • Added FMPoseConfig and sub-config dataclasses with helpers (from_namespace, to_dict) plus unit tests.
  • Implemented a model registry (register_model / get_model) and migrated main scripts to select models via --model_type.
  • Restructured the FMPose3D model into a subpackage and registered it under "fmpose3d".

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
tests/test_config.py Adds tests validating defaults and namespace/dict conversion for new config dataclasses.
scripts/FMPose3D_train.sh Switches CLI usage from --model_path to --model_type.
scripts/FMPose3D_test.sh Switches CLI usage from --model_path to --model_type.
scripts/FMPose3D_main.py Uses registry get_model(args.model_type) instead of importing/loading model from a file path.
fmpose3d/models/fmpose3d/model_GAMLP.py Registers the FMPose3D model and updates imports to new package structure.
fmpose3d/models/fmpose3d/graph_frames.py Minor formatting-only change.
fmpose3d/models/fmpose3d/__init__.py New subpackage initializer exporting Graph and Model.
fmpose3d/models/base_model.py Adds model registry and BaseModel abstraction.
fmpose3d/models/__init__.py Exposes registry APIs and imports model subpackages so registration executes.
fmpose3d/common/config.py Adds configuration dataclasses and FMPoseConfig composition utilities.
fmpose3d/common/arguments.py Replaces --model_path with --model_type argument.
fmpose3d/common/__init__.py Re-exports new config objects from fmpose3d.common.
fmpose3d/animals/common/arguments.py Replaces --model_path with --model_type argument for animals pipeline.
demo/vis_in_the_wild.sh Switches demo script to --model_type (but currently hardcodes an absolute weights path).
demo/vis_in_the_wild.py Uses registry get_model(args.model_type) instead of loading a model from a file path.
animals/scripts/train_animal3d.sh Switches animals training script to pass --model_type.
animals/scripts/test_animal3d.sh Switches animals test script to pass --model_type.
animals/scripts/main_animal3d.py Uses registry get_model(args.model_type) for animals pipeline.
animals/demo/vis_animals.sh Switches animals demo script to pass --model_type.
animals/demo/vis_animals.py Uses registry get_model(args.model_type) for animals demo.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +21 to +22
_MODEL_REGISTRY: dict[str, type["BaseModel"]] = {}

Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

pyproject.toml declares requires-python = ">=3.8", but this module uses PEP 585 built-in generics (dict[str, ...]) which will raise a TypeError on Python 3.8 at import time. Use typing.Dict/typing.Type (or add from __future__ import annotations and bump the minimum supported Python to >=3.9) to keep compatibility.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@xiu-cs can we bump the python version or are we somehow restricted to python 3.8?

Copy link
Member

Choose a reason for hiding this comment

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

from 3.10+ is better (and more accurate!)

Comment on lines +67 to +69
def list_models() -> list[str]:
"""Return a sorted list of all registered model names."""
return sorted(_MODEL_REGISTRY)
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

list[str] is also a PEP 585 built-in generic and is not supported on Python 3.8 (the current minimum version in pyproject.toml). Please switch this return annotation to typing.List[str] (or bump the minimum supported Python version).

Copilot uses AI. Check for mistakes.
@deruyter92 deruyter92 force-pushed the jaap/add_config_and_registry branch from 4583e94 to b73d9ce Compare February 9, 2026 15:44
@MMathisLab MMathisLab added the enhancement New feature or request label Feb 9, 2026
@xiu-cs
Copy link
Collaborator

xiu-cs commented Feb 9, 2026

@deruyter92 Thanks a lot! I like the new structure.

@AdaptiveMotorControlLab AdaptiveMotorControlLab deleted a comment from Copilot AI Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants