Skip to main content
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
image_data
string
required

Base64-encoded PNG tile. (The SDK also accepts a PIL Image or raw bytes.)

slide_name
string
required

Stem of the source slide filename.

x
integer
required

Tile x-coordinate in the slide.

y
integer
required

Tile y-coordinate in the slide.

width
integer
required

Tile width in pixels.

height
integer
required

Tile height in pixels.

patch_idx
integer
required

Index of this tile in the extraction plan.

bulk_rna
number[] | null

Optional bulk RNA counts vector (M-Optimus prediction only).

tissue_ratio
number | null

Fraction of tissue in the tile.

resolution
number | null

Extraction resolution in microns per pixel.

Response

Mask result

output
number[]

Model output vector: embeddings (1536), gene predictions, or a flattened mask.

slide_name
string
x
integer
y
integer
width
integer
height
integer
tissue_ratio
number | null
patch_idx
integer
resolution
number | null