Skip to content

Conversation

bonheml
Copy link
Contributor

@bonheml bonheml commented Aug 7, 2025

This PR implements a local version of Titan to avoid the boilerplate described in #118.

Specifically, it adds:

  • QC methods in BaseSlideEncoder to ensure that registry paths are valid and that an internet connection is available. These methods mirror the QC methods of the BasePatchEncoder for consistency.
  • If a folder is provided for Titan in local_ckpts.json, it will now be used if valid. If no path is given, the online version of Titan will be used, provided an internet connection is available.

As mentioned in #118, the files in Titan may need some updates to run correctly in Trident.
This is something that I did not do in this PR, as I am unsure if this may be updated in the Titan repo later on.

bonheml added 3 commits August 7, 2025 09:21
This is done in the same fashion as BasePatchEncoder QC check:
- Add an attribute _has_internet to BaseSlideEncoder which is used by ensure_has_internet
- Add an attribute weights_path, which can optionnaly be set during init
- Add a method ensure_valid_weights_path to verify that the provided
  weights path is valid
- Add a method ensure_has_internet to verify that the online model can
  be loaded
- Add a method _get_weights_path which will use self.weights_path
  if provided or check the model registry to get the weights_path
  otherwise. In both cases, the validity of the path will be checked
  using ensure_valid_weights_path.
Use the newly added _get_weights_path method to use an optional
weights_path given during init or look at the path in the model
registry.
If a valid path is found, the load the offline model from there.
Otherwise, ensure that there is an internet access, then use the
online version of Titan.
Add the key "titan" to local_ckpts.json and leave the path empty, as
done in patch encoder models.
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.

1 participant