Skip to content

Commit

Permalink
Merge pull request #54 from qupath/download-models
Browse files Browse the repository at this point in the history
Download models
  • Loading branch information
petebankhead authored Sep 5, 2024
2 parents 31c0902 + 8c3e32d commit 8e8d05b
Show file tree
Hide file tree
Showing 10 changed files with 696 additions and 185 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ dependencies {
shadow libs.qupath.fxtras
shadow libs.bioimageio.spec
shadow libs.deepJavaLibrary
shadow libs.commonmark

implementation 'io.github.qupath:qupath-extension-djl:0.3.0'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ private DetectionMeasurer(Collection<ObjectMeasurements.Compartments> compartmen
Collection<ObjectMeasurements.ShapeFeatures> shapeFeatures,
double downsample) {
this.shapeFeatures = shapeFeatures;
this.downsample = downsample;
this.compartments = compartments;
this.measurements = measurements;
this.downsample = downsample;
}

/**
Expand Down
19 changes: 7 additions & 12 deletions src/main/java/qupath/ext/instanseg/core/InstanSeg.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.stream.IntStream;
Expand Down Expand Up @@ -136,8 +137,11 @@ private InstanSegResults runInstanSeg(Collection<? extends PathObject> pathObjec

long startTime = System.currentTimeMillis();

Path modelPath;
modelPath = model.getPath().resolve("instanseg.pt");
Optional<Path> oModelPath = model.getPath();
if (!oModelPath.isPresent()) {
return new InstanSegResults(0, 0, 0, 0, 0);
}
Path modelPath = oModelPath.get().resolve("instanseg.pt");
int nPredictors = 1; // todo: change me?

// Optionally pad images so that every tile has the required size.
Expand All @@ -162,7 +166,7 @@ private InstanSegResults runInstanSeg(Collection<? extends PathObject> pathObjec
// Create an int[] representing a boolean array of channels to use
boolean[] outputChannelArray = null;
if (outputChannels != null && outputChannels.length > 0) {
outputChannelArray = new boolean[model.getOutputChannels()];;
outputChannelArray = new boolean[model.getOutputChannels().get()]; // safe to call get because of previous checks
for (int c : outputChannels) {
if (c < 0 || c >= outputChannelArray.length) {
throw new IllegalArgumentException("Invalid channel index: " + c);
Expand Down Expand Up @@ -514,15 +518,6 @@ public Builder modelPath(String path) throws IOException {
return modelPath(Path.of(path));
}

/**
* Set the specific model to be used
* @param name The name of a built-in model
* @return A modified builder
*/
public Builder modelName(String name) {
return model(InstanSegModel.fromName(name));
}

/**
* Set the device to be used
* @param deviceName The name of the device to be used (eg, "gpu", "mps").
Expand Down
Loading

0 comments on commit 8e8d05b

Please sign in to comment.