-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from ksugar/dev
0.4.0 -> 0.4.1
- Loading branch information
Showing
9 changed files
with
171 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import org.elephant.sam.entities.SAMType; | ||
import org.elephant.sam.entities.SAMOutput; | ||
import org.elephant.sam.tasks.SAMDetectionTask; | ||
import qupath.lib.roi.RectangleROI; | ||
|
||
// Given that you have the following data in .csv | ||
def data = [ | ||
['id', 'x', 'y', 'w', 'h'], | ||
['0', '411', '84', '31', '33'], | ||
['1', '413', '170', '32', '37'] | ||
] | ||
def fileOut = File.createTempFile('bbox', '.csv'); | ||
fileOut.text = data*.join(',').join(System.lineSeparator()); | ||
|
||
// Read the data from the file | ||
def fileIn = new File(fileOut.path); | ||
def rows = fileIn.readLines().tail()*.split(','); | ||
def plane = getCurrentViewer().getImagePlane(); | ||
def bboxes = rows.collect { | ||
PathObjects.createAnnotationObject( | ||
ROIs.createRectangleROI( | ||
it[1] as Double, | ||
it[2] as Double, | ||
it[3] as Double, | ||
it[4] as Double, | ||
plane | ||
) | ||
) | ||
} | ||
|
||
def task = SAMDetectionTask.builder(getCurrentViewer()) | ||
.serverURL("http://localhost:8000/sam/") | ||
.addForegroundPrompts(bboxes) | ||
.addBackgroundPrompts(Collections.emptyList()) | ||
.model(SAMType.VIT_L) | ||
.outputType(SAMOutput.MULTI_SMALLEST) | ||
.setName(true) | ||
.setRandomColor(true) | ||
.build(); | ||
Platform.runLater(task); | ||
def annotations = task.get(); | ||
addObjects(annotations); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import org.elephant.sam.entities.SAMType; | ||
import org.elephant.sam.entities.SAMOutput; | ||
import org.elephant.sam.tasks.SAMAutoMaskTask; | ||
|
||
def task = SAMAutoMaskTask.builder(getCurrentViewer()) | ||
.serverURL("http://localhost:8000/sam/") | ||
.model(SAMType.VIT_L) | ||
.outputType(SAMOutput.MULTI_SMALLEST) | ||
.setName(true) | ||
.clearCurrentObjects(true) | ||
.setRandomColor(true) | ||
.pointsPerSide(16) | ||
.pointsPerBatch(64) | ||
.predIoUThresh(0.88) | ||
.stabilityScoreThresh(0.95) | ||
.stabilityScoreOffset(1.0) | ||
.boxNmsThresh(0.2) | ||
.cropNLayers(0) | ||
.cropNmsThresh(0.7) | ||
.cropOverlapRatio(512 / 1500) | ||
.cropNPointsDownscaleFactor(1) | ||
.minMaskRegionArea(0) | ||
.includeImageEdge(true) | ||
.build(); | ||
Platform.runLater(task); |