Tissue segmentation
curl --request POST \
--url http://localhost:8080/api/predict/tissue-seg \
--header 'Content-Type: application/json' \
--data '
{
"image_data": "<base64-png-512x512>",
"slide_name": "slide_A",
"x": 0,
"y": 0,
"width": 512,
"height": 512,
"tissue_ratio": null,
"patch_idx": 0,
"resolution": 8
}
'import requests
url = "http://localhost:8080/api/predict/tissue-seg"
payload = {
"image_data": "<base64-png-512x512>",
"slide_name": "slide_A",
"x": 0,
"y": 0,
"width": 512,
"height": 512,
"tissue_ratio": None,
"patch_idx": 0,
"resolution": 8
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
image_data: '<base64-png-512x512>',
slide_name: 'slide_A',
x: 0,
y: 0,
width: 512,
height: 512,
tissue_ratio: null,
patch_idx: 0,
resolution: 8
})
};
fetch('http://localhost:8080/api/predict/tissue-seg', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8080",
CURLOPT_URL => "http://localhost:8080/api/predict/tissue-seg",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'image_data' => '<base64-png-512x512>',
'slide_name' => 'slide_A',
'x' => 0,
'y' => 0,
'width' => 512,
'height' => 512,
'tissue_ratio' => null,
'patch_idx' => 0,
'resolution' => 8
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:8080/api/predict/tissue-seg"
payload := strings.NewReader("{\n \"image_data\": \"<base64-png-512x512>\",\n \"slide_name\": \"slide_A\",\n \"x\": 0,\n \"y\": 0,\n \"width\": 512,\n \"height\": 512,\n \"tissue_ratio\": null,\n \"patch_idx\": 0,\n \"resolution\": 8\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:8080/api/predict/tissue-seg")
.header("Content-Type", "application/json")
.body("{\n \"image_data\": \"<base64-png-512x512>\",\n \"slide_name\": \"slide_A\",\n \"x\": 0,\n \"y\": 0,\n \"width\": 512,\n \"height\": 512,\n \"tissue_ratio\": null,\n \"patch_idx\": 0,\n \"resolution\": 8\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8080/api/predict/tissue-seg")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"image_data\": \"<base64-png-512x512>\",\n \"slide_name\": \"slide_A\",\n \"x\": 0,\n \"y\": 0,\n \"width\": 512,\n \"height\": 512,\n \"tissue_ratio\": null,\n \"patch_idx\": 0,\n \"resolution\": 8\n}"
response = http.request(request)
puts response.read_body{
"output": [
123
],
"slide_name": "<string>",
"x": 123,
"y": 123,
"width": 123,
"height": 123,
"tissue_ratio": 123,
"patch_idx": 123,
"resolution": 123
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}{
"detail": "Internal server error"
}{
"status": "loading"
}Prediction
Tissue segmentation
Generate a tissue segmentation mask for a tile. Input: a 512×512 tile at 8.0 MPP. Output: a flattened binary mask (0/1) of length H×W in output.
POST
/
api
/
predict
/
tissue-seg
Tissue segmentation
curl --request POST \
--url http://localhost:8080/api/predict/tissue-seg \
--header 'Content-Type: application/json' \
--data '
{
"image_data": "<base64-png-512x512>",
"slide_name": "slide_A",
"x": 0,
"y": 0,
"width": 512,
"height": 512,
"tissue_ratio": null,
"patch_idx": 0,
"resolution": 8
}
'import requests
url = "http://localhost:8080/api/predict/tissue-seg"
payload = {
"image_data": "<base64-png-512x512>",
"slide_name": "slide_A",
"x": 0,
"y": 0,
"width": 512,
"height": 512,
"tissue_ratio": None,
"patch_idx": 0,
"resolution": 8
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
image_data: '<base64-png-512x512>',
slide_name: 'slide_A',
x: 0,
y: 0,
width: 512,
height: 512,
tissue_ratio: null,
patch_idx: 0,
resolution: 8
})
};
fetch('http://localhost:8080/api/predict/tissue-seg', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8080",
CURLOPT_URL => "http://localhost:8080/api/predict/tissue-seg",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'image_data' => '<base64-png-512x512>',
'slide_name' => 'slide_A',
'x' => 0,
'y' => 0,
'width' => 512,
'height' => 512,
'tissue_ratio' => null,
'patch_idx' => 0,
'resolution' => 8
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:8080/api/predict/tissue-seg"
payload := strings.NewReader("{\n \"image_data\": \"<base64-png-512x512>\",\n \"slide_name\": \"slide_A\",\n \"x\": 0,\n \"y\": 0,\n \"width\": 512,\n \"height\": 512,\n \"tissue_ratio\": null,\n \"patch_idx\": 0,\n \"resolution\": 8\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:8080/api/predict/tissue-seg")
.header("Content-Type", "application/json")
.body("{\n \"image_data\": \"<base64-png-512x512>\",\n \"slide_name\": \"slide_A\",\n \"x\": 0,\n \"y\": 0,\n \"width\": 512,\n \"height\": 512,\n \"tissue_ratio\": null,\n \"patch_idx\": 0,\n \"resolution\": 8\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8080/api/predict/tissue-seg")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"image_data\": \"<base64-png-512x512>\",\n \"slide_name\": \"slide_A\",\n \"x\": 0,\n \"y\": 0,\n \"width\": 512,\n \"height\": 512,\n \"tissue_ratio\": null,\n \"patch_idx\": 0,\n \"resolution\": 8\n}"
response = http.request(request)
puts response.read_body{
"output": [
123
],
"slide_name": "<string>",
"x": 123,
"y": 123,
"width": 123,
"height": 123,
"tissue_ratio": 123,
"patch_idx": 123,
"resolution": 123
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}{
"detail": "Internal server error"
}{
"status": "loading"
}Body
application/json
Base64-encoded PNG tile. (The SDK also accepts a PIL Image or raw bytes.)
Stem of the source slide filename.
Tile x-coordinate in the slide.
Tile y-coordinate in the slide.
Tile width in pixels.
Tile height in pixels.
Index of this tile in the extraction plan.
Optional bulk RNA counts vector (M-Optimus prediction only).
Fraction of tissue in the tile.
Extraction resolution in microns per pixel.
Was this page helpful?
⌘I

