Skip to content

Commit 60c9517

Browse files
authored
Merge pull request #168 from petebankhead/djl
Update to more recent DJL API
2 parents d793f99 + f9511ff commit 60c9517

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

docs/deep/djl.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Here, we access all the artifacts available for object detection, and select the
8989
import qupath.ext.djl.*
9090

9191
var artifacts = DjlZoo.listObjectDetectionModels()
92-
var firstArtifact = artifacts[0]
92+
var firstArtifact = artifacts[0].getDefaultArtifact()
9393
println(firstArtifact)
9494
```
9595

@@ -99,7 +99,7 @@ We can see a bit more by converting the artifact to JSON:
9999
import qupath.ext.djl.*
100100

101101
var artifacts = DjlZoo.listObjectDetectionModels()
102-
var firstArtifact = artifacts[0]
102+
var firstArtifact = artifacts[0].getDefaultArtifact()
103103
var json = GsonTools.getInstance(true).toJson(firstArtifact)
104104
println(json)
105105
```
@@ -142,7 +142,7 @@ boolean allowDownsamples = true
142142

143143
// Get an object detection model from the zoo
144144
var artifacts = DjlZoo.listObjectDetectionModels()
145-
var artifact = artifacts[0]
145+
var artifact = artifacts[0].getDefaultArtifact()
146146

147147
// Load the model
148148
var criteria = DjlZoo.loadModel(artifact, allowDownsamples)
@@ -192,7 +192,7 @@ import qupath.ext.djl.*
192192
// Get a semantic segmentation model
193193
boolean allowDownloads = true
194194
var artifacts = DjlZoo.listSemanticSegmentationModels()
195-
var artifact = artifacts[0]
195+
var artifact = artifacts[0].getDefaultArtifact()
196196
println artifact
197197

198198
// Apply the model
@@ -224,8 +224,8 @@ import ai.djl.Application.CV
224224

225225
// Get all the image generation models with an 'artist' property
226226
// Note that other image generation models may not work (since they expect different inputs)
227-
var artifacts = DjlZoo.listModels(CV.IMAGE_GENERATION)
228-
artifacts = artifacts.findAll(a -> a.properties.getOrDefault("artist", null))
227+
var models = DjlZoo.listModels(CV.IMAGE_GENERATION)
228+
var artifacts = models.findAll(a -> a.getDefaultArtifact().properties.getOrDefault("artist", null))[0].listArtifacts()
229229

230230
// Get an image
231231
// Note: this shouldn't be too big! Define a maximum dimension
@@ -290,7 +290,8 @@ import ai.djl.Application.CV
290290
import qupath.lib.gui.viewer.overlays.*
291291

292292
// Get all the image generation models with an 'artist' property
293-
var artifacts = DjlZoo.listModels(CV.IMAGE_GENERATION)
293+
var models = DjlZoo.listModels(CV.IMAGE_GENERATION)
294+
var artifacts = models.findAll(a -> a.getDefaultArtifact().properties.getOrDefault("artist", null))[0].listArtifacts()
294295
var artifact = artifacts.find(a -> a.properties["artist"] == "vangogh")
295296

296297
// Get an image

0 commit comments

Comments
 (0)