Zum Inhalt springen

Segment Anything Model 2 · Image

Integrieren

Modell-ID sam2/image
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.com/v1/run/sam2/image?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
  }'

# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.com/v1/requests/REQUEST_ID?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY"

Diese Anfrage: ≈0,002 $ 2 API-Credits Auf dieser Seite ausführen

API-Schlüssel abrufen
Meta Bildbearbeitung #segmentation#mask#real-time

Segmentiert Objekte in einem einzelnen Bild anhand von Punkt- oder Box-Prompts und gibt eine Maske oder das maskierte Bild zurück

Meta · Bild

Dein erstes Ergebnis erscheint hier

Erstelle unten eine Anfrage und führe sie mit deinem API-Schlüssel aus. Ausgaben werden in unseren Speicher kopiert und dauerhaft oder 7 Tage kostenlos aufbewahrt.

Anfrage erstellen

Die Steuerelemente werden aus dem Modellschema generiert. Code und Preis werden aktualisiert, während du sie änderst.

•erforderlich image_url
Datei ablegen oder

URL des zu segmentierenden Bilds.

Erweitert output_format · apply_mask · prompts · box_prompts
output_format Standard png

Dateiformat des resultierenden Bilds.

Standard []

Für die Bildsegmentierung verwendete Prompts.

Standard []

Koordinaten der Boxgrenzen.

POST /run/sam2/image?wait=20 Preis → 0,002 $
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.com/v1/run/sam2/image?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
  }'

# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.com/v1/requests/REQUEST_ID?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY"

Diese Anfrage ausführen

Dein Schlüssel bleibt in diesem Browser: Er wird nur an die Doitong API gesendet und nur gespeichert (localStorage), wenn du „Merken“ aktivierst. API-Schlüssel abrufen

Über Segment Anything Model 2 · Image

Segmentiert ein Bild mit SAM 2 anhand von Punkt-Prompts (`prompts`) oder Box-Koordinaten (`box_prompts`). Setzen Sie `apply_mask` auf true, um die auf das Bild angewendete Maske statt nur der Maske zu erhalten. Die Ausgabe kann als jpeg, png oder webp gespeichert werden, standardmäßig als png. Pro Anfrage wird eine Bild-URL akzeptiert.

Parameter

Sende entweder den kanonischen Namen oder den nativen Namen, nicht beide. Kanonische Namen

NameTyp StandardZulässig Beschreibung
image_urlerforderlich image
Typurl · image
URL des zu segmentierenden Bilds.
promptsoptional
Typobject[]
Standard[]
Für die Bildsegmentierung verwendete Prompts.
prompts[].xoptional
Typinteger
Standard305
Prompt-Position auf der X-Achse.
prompts[].yoptional
Typinteger
Standard350
Prompt-Position auf der Y-Achse.
prompts[].labeloptional
Typenum
Standard1
01
Prompt-Label: 1 steht für Vordergrund, 0 für Hintergrund.
prompts[].frame_indexoptional
Typinteger
Standard0
Index zur Identifizierung des Frames für die Interaktion.
box_promptsoptional
Typobject[]
Standard[]
Koordinaten der Boxgrenzen.
box_prompts[].x_minoptional
Typinteger
Standard0
Minimaler x-Koordinatenwert der Box.
box_prompts[].y_minoptional
Typinteger
Standard0
Minimaler y-Koordinatenwert der Box.
box_prompts[].x_maxoptional
Typinteger
Standard0
Maximaler x-Koordinatenwert des Prompts.
box_prompts[].y_maxoptional
Typinteger
Standard0
Maximaler y-Koordinatenwert des Prompts.
box_prompts[].frame_indexoptional
Typinteger
Standard0
Index zur Identifizierung des Frames für die Interaktion.
apply_maskoptional
Typboolean
Standardfalse
Steuert, ob die Maske auf das Bild angewendet wird.
output_formatoptional
Typenum
Standardpng
jpegpngwebp
Dateiformat des resultierenden Bilds.
erforderlich Kanonischer Name, ebenfalls akzeptiert

Dateiparameter akzeptieren eine öffentliche https://-URL, eine data:-URI bis 10 MB oder die file_url eines Uploads. Dateien

Ausgabe

GET /requests/req_8k2m4q7x1z9c3v5b6n0p2r4t
{
  "id": "req_8k2m4q7x1z9c3v5b6n0p2r4t",
  "object": "request",
  "model": "sam2/image",
  "status": "succeeded",
  "created_at": "2026-10-20T12:00:00Z",
  "started_at": "2026-10-20T12:00:02Z",
  "completed_at": "2026-10-20T12:00:09Z",
  "queue_position": null,
  "cost": {
    "credits": 2,
    "usd": "0.002",
    "charged": 2,
    "refunded": 0
  },
  "input": {
    "image_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
  },
  "output": {
    "image": {
      "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
      "content_type": "image/jpeg",
      "file_name": "0-output.jpeg",
      "file_size": 1843200,
      "width": 1024,
      "height": 768
    }
  },
  "outputs": [
    {
      "type": "image",
      "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
      "content_type": "image/jpeg",
      "file_size": 1843200,
      "width": 1024,
      "height": 768,
      "stored": true
    }
  ],
  "error": null,
  "metrics": {
    "inference_seconds": 6.8
  },
  "urls": {
    "self": "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t",
    "cancel": "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t/cancel"
  }
}
Deine Dateien, deine EntscheidungJede outputs[].url ist eine Kopie in unserem Speicher: dauerhaft aufbewahrt (Abrechnung pro GB-Monat) oder 7 Tage kostenlos – je nach Kontoeinstellung oder ?storage=.
Gleiche Struktur bei jedem Modelltype, url, content_type, width, height und duration – für Bilder, Video und Audio gleichermaßen. output ist das Ergebnisobjekt des Modells.
Ausgabefelder
image
object {url, content_type, file_name, file_size, width, height}Bild mit angewendeter Segmentierung.

Weitere Modelle: Bildbearbeitung

Für KI-Agenten: Diese Seite ist als Markdown verfügbar unter https://doitong.com/de/developers/models/sam2/image.md. Alle Modelle und Anleitungen: https://doitong.com/developers/llms.txt