TEED Edge Detection

TEED_EDGE_DETECTION

Draws the edges and fine lines of a picture as a clean edge map, soft or pure black and white, the kind of line map used to guide image generation. Fine-tune it on your own pictures and edge maps.

Utilitiesedge-detectionsoft-edgeline-artimage-processingmitFine-tunable
TEED Edge Detection: Utilities model on Kainguru

About TEED Edge Detection

Capabilities

  • Edge map — white lines on black from any picture, as soft 8-bit gray or thresholded to pure black and white
  • Full-size results — the map has the picture's own width and height
  • Tiny and fast — 58,910 weights, so even large pictures take a moment
  • Fine-tunable — train it on your own pictures and the edge maps you want from them

Good to know

  • Pictures up to 30 MB and 40 megapixels, as PNG, JPEG or WebP, at least 16 pixels a side. The network sees the picture with its longer side at most 2048 pixels (one with a side under 512 pixels is first enlarged 1.5 times) and the map is scaled back to the picture's size.
  • The soft style returns the edge strength as gray, white = edge, stretched from the picture's faintest to its strongest response as the authors' own code does, so a picture with no real edges comes out dark; the binary style turns every pixel at or above the threshold (0.5 by default) white and the rest black.
  • Fine-tuning takes one ZIP (at most 4 GB, 5000 entries, no password) with 4 to 1000 pictures (each up to 30 MB and 40 megapixels), an edge map for each and a manifest.jsonl with one line per pair: {"file": "photos/a.jpg", "edges": "edges/a.png"}. Paths are relative to the manifest, and manifest.jsonl is at most 16 MB.
  • An edge map has its picture's size as displayed (after its EXIF rotation): a grayscale PNG, JPEG or WebP, white = edge, black = no edge; a map with no edge in it is refused.
  • Training uses random 352 x 352 crops (mirrored half the time) of pictures kept at 1024 pixels on the longer side, and the authors' loss; it stops after 10,000 steps or 9 hours, whichever comes first, and keeps what it learned.

Attribution

TEED (Tiny and Efficient Edge Detector) by Xavier Soria Poma, released under the MIT License, Copyright (c) 2022 Xavier Soria Poma.

TEED Edge Detection inputs and output

NameTypeRequiredDefaultDetails
imagefileYes—The picture: PNG, JPEG or WebP, at most 30 MB and 40 megapixels, at least 16 pixels a side.
1–2048 characters · image/png, jpeg, webp
thresholdnumberNo0.5For the binary style: the lowest edge strength (0 to 1) that becomes white; lower keeps more, fainter edges.
0.01–0.99
styletextNosoftsoft: the edge strength as 8-bit gray, white = edge; binary: pure white edges on black, wherever the strength reaches the threshold.
Allowed: soft, binary

Output. Returns PNG image: PNG at the picture's size: the edge map, 8-bit grayscale, white = edge.

Run TEED Edge Detection with the API

Send your API key in the X-API-Key header. The run is asynchronous: submit it, then poll it until it finishes. Create an API key.

cURL
curl -X POST "https://api.kainguru.com/api/v1/executions?mlFlowId=TEED_EDGE_DETECTION" \
  -H "X-API-Key: kg_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "input": {
    "image": "https://example.com/input.png",
    "style": "soft",
    "threshold": 0.5
  },
  "outputFormat": "json"
}'

# Poll until the execution reaches a terminal state
curl "https://api.kainguru.com/api/v1/executions/{executionId}" \
  -H "X-API-Key: kg_your_api_key"
Python
from kainguru import KainguruClient

with KainguruClient(api_key="kg_your_api_key", base_url="https://api.kainguru.com/api") as client:
    submitted = client.executions.execute(
        "TEED_EDGE_DETECTION",
        {
          "image": "https://example.com/input.png",
          "style": "soft",
          "threshold": 0.5
        },
        output_format="json",
    )
    result = client.executions.await_completion(submitted.id)
    print(result.execution.output)

Fine-tune TEED Edge Detection

You can fine-tune TEED Edge Detection on your own data and run the tuned model through the same API. Dataset: One ZIP (at most 4 GB, no password) with 4 to 1000 pictures, an edge map for each and a manifest.jsonl with one {"file", "edges"} line per pair. More rules: Good to know, in the README.

The steps are in the docs.

TEED Edge Detection pricing

Price per image: 0.0874 credits ($0.000874). The price is shown again before every run; all prices are on the pricing page.

Licence and source

BiRefNet General: Utilities model on Kainguru
Utilities

BiRefNet General

Removes the background from a photo and returns the subject on a transparent background, or as a black-and-white mask.

Fine-tunable
Cloth Segmentation U2-Net: Utilities model on Kainguru
Utilities

Cloth Segmentation U2-Net

Finds the clothes a person wears in a photo and returns a mask for the upper body, the lower body and full-body…

Fine-tunable
EoMT Large COCO Panoptic: Utilities model on Kainguru
Utilities

EoMT Large COCO Panoptic

Splits a picture into its objects and regions, such as people, cars, sky and road, with a label and a mask for each one.

Fine-tunable
InSPyReNet: Utilities model on Kainguru
Utilities

InSPyReNet

Removes the background from a photo with fine detail at hair and edges, and returns the subject on a transparent…

Fine-tunable
MoGe-2 ViT-L Normal: Utilities model on Kainguru
Utilities

MoGe-2 ViT-L Normal

Estimates metric depth, surface normals and the camera's field of view from a single photo of any scene, indoors or out.

Fine-tunable
RetinaFace ResNet-50: Utilities model on Kainguru
Utilities

RetinaFace ResNet-50

Finds every face in a photo and returns a box around each one with five landmarks, the eyes, the nose tip and the…

Fine-tunable