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

Pass optional arguments #121

Merged
merged 8 commits into from
Jan 17, 2025
Merged

Conversation

alanocallaghan
Copy link
Collaborator

Add the ability to pass optional arguments to InstanSeg models.

Example:

  qupath.ext.instanseg.core.InstanSeg.builder()
      .modelPath("/path/to/model/")
      .arg("seed_threshold", 0.9999)
      .build()
      .detectObjects()

or equivalently

qupath.ext.instanseg.core.InstanSeg.builder()
    .modelPath("/path/to/model/")
    .args(["seed_threshold": 0.9999])
    .build()
    .detectObjects()

Copy link
Member

@petebankhead petebankhead left a comment

Choose a reason for hiding this comment

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

Think I might have inadvertently left comments pending but not submitted...

The main one is that I think we should use LinkedHashMap instead of HashMap, since insertion order could matter (even if only through a bug/regression) and I don't see any benefit in allowing HashMap to mess with this.

Also, defensive copies are cheap relative to the trouble failing to make them might cause us one day.

for (var es : optionalArgs.entrySet()) {
var val = es.getValue();
NDArray array = null;
switch (val) {
Copy link
Member

Choose a reason for hiding this comment

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

Ah, so that's how you do it... wanted to use a switch originally, but didn't know the syntax :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You can thank IntelliJ's linting, I just alt-enter stuff and keep it if I think it's better

src/main/java/qupath/ext/instanseg/core/InstanSeg.java Outdated Show resolved Hide resolved
@alanocallaghan alanocallaghan merged commit c890cdf into qupath:main Jan 17, 2025
1 check passed
@alanocallaghan alanocallaghan deleted the optional-args branch January 17, 2025 16:15
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