Skip to content

Commit

Permalink
Improve tile size & device defaults
Browse files Browse the repository at this point in the history
Padding is currently 80 and we subtract 2 x padding from tile size to get the valid area. So 512 is a better default than 256, which has a tiny valid area.
  • Loading branch information
petebankhead committed Sep 5, 2024
1 parent cb6de7a commit 8c3e32d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/main/java/qupath/ext/instanseg/ui/InstanSegPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.Property;
import javafx.beans.property.StringProperty;
import qupath.lib.common.GeneralTools;
import qupath.lib.gui.prefs.PathPrefs;

class InstanSegPreferences {
Expand All @@ -17,15 +18,28 @@ private InstanSegPreferences() {

private static final StringProperty preferredDeviceProperty = PathPrefs.createPersistentPreference(
"instanseg.pref.device",
"cpu");
getDefaultDevice());

private static final Property<Integer> numThreadsProperty = PathPrefs.createPersistentPreference(
"instanseg.num.threads",
Math.min(4, Runtime.getRuntime().availableProcessors())).asObject();

private static final IntegerProperty tileSizeProperty = PathPrefs.createPersistentPreference(
"intanseg.tile.size",
256);
512);

/**
* MPS should work reliably (and much faster) on Apple Silicon, so set as default.
* Everywhere else, use CPU as we can't count on a GPU/CUDA being available.
* @return
*/
private static String getDefaultDevice() {
if (GeneralTools.isMac() && "aarch64".equals(System.getProperty("os.arch"))) {
return "mps";
} else {
return "cpu";
}
}

static StringProperty modelDirectoryProperty() {
return modelDirectoryProperty;
Expand Down

0 comments on commit 8c3e32d

Please sign in to comment.