Moderation / Modes and censoring
Moderation

Modes and censoring

Choose what a Detectivision check returns with mode: detect for a verdict, capture for each finding and where it is, censor for a copy with findings hidden.

On this page

Note

Text and image flags judge the whole text or image: answers have no positions, and capture and censor return what detect returns, at the same price. Video and live stream flags say where each finding is.

mode sets how much a check can return and what it can cost. capture is the default. Positions, censored copies and masked text come only from flags with positions: the flags of video and live streams have them, those of text and images do not.

Mode You get Text Image Video Live stream
detect The flags raised and their confidence. 1 credit 1 credit 1 credit 1 credit
capture (default) Also detections for each flag. A flag with positions says where it was found: boxes in images and videos, the second in videos, word positions in text. 1 credit 1 credit 2 credits 2 credits
censor Also a censored copy of what flags with positions found: the image or video with findings hidden, or the text with flagged words masked. 1 credit 1 credit 2 credits 2 credits

A text is priced per started 2,500 characters, a video per started 60 frames checked and a live session per minute at 1 fps. These are async prices; an answer given at once (the default) costs twice as much, except a live session. capture and censor cost one credit more than detect only when one of the flags you check has positions in an image or a video. Text and image flags have none, so every mode costs what detect costs for them. See Credits and billing.

Live sessions take the same three modes.

detect#

Use it when you only need a verdict, for example to reject an upload. An example answer:

{
  "mode": "detect",
  "flagged": true,
  "flags": [{ "flag": "sexual", "confidence": 0.91 }],
  "usage": { "charged": 2, "remaining": 28 }
}

capture#

Adds detections to every flag. For text and image flags a detection has a label and a confidence and no position, so capture tells you no more than detect.

A flag with positions adds bbox (and polygon when available) for images and videos, plus t and frame for videos, and start and end for text. The flags of video and live streams have positions; those of text and images do not. See Responses.

censor#

For text and images censor answers like capture and costs the same: text comes back in censoredText exactly as you sent it, and no image copy is made. Videos and live streams get a copy with what their flags found hidden; what follows describes the copies.

Images and videos#

The copy hides every detection that has a position. Choose how with censorStyle:

censorStyle Effect
blur (default) A strong blur over each region.
pixelate Large pixels over each region.
box A solid black box over each region.
{
  "type": "image_moderation",
  "input": "https://example.com/photo.jpg",
  "mode": "censor",
  "censorStyle": "pixelate"
}

When a copy is made, the answer has censored. Its shape, for an image (a video's contentType is video/mp4):

{
  "censored": {
    "contentType": "image/jpeg",
    "regions": 2,
    "url": "https://api.detectivision.ai/api/v1/moderation/1043/censored"
  }
}

A copy is downloaded with any API key of your account:

curl -o censored.jpg https://api.detectivision.ai/api/v1/moderation/1043/censored \
  -H "Api-Key: $DETECTIVISION_API_KEY"
r = requests.get(result["censored"]["url"], headers={"Api-Key": os.environ["DETECTIVISION_API_KEY"]})
open("censored.jpg", "wb").write(r.content)
const file = await fetch(result.censored.url, { headers: { "Api-Key": process.env.DETECTIVISION_API_KEY } });
await writeFile("censored.jpg", Buffer.from(await file.arrayBuffer()));
  • Images come back as JPEG; videos as H.264 MP4 (playable in every browser).
  • If the copy could not be kept, censored has an error instead of a url. The check is still charged; run it again to get a copy.
  • Download the copy and serve it from your own storage. 404 Not found means the id is unknown, belongs to another account, or has no copy.

Text#

With mode: "censor", text results include censoredText: the text with every non-space character of the flagged spans replaced by *, keeping the length. Only flags with positions are masked. Text flags judge the whole text, so censoredText is your text unchanged.