For the complete documentation index, see llms.txt. This page is also available as Markdown.

इमेजें प्रबंधित करें

REST API और Python SDK के माध्यम से अलग-अलग इमेजें अपलोड, एनोटेट, निरीक्षण, टैग और हटाएँ।

के बारे में

Roboflow आपको REST API और Python SDK के माध्यम से किसी प्रोजेक्ट में अलग-अलग छवियाँ अपलोड, एनोटेट, निरीक्षण, टैग और हटाने की सुविधा देता है। जब आपको बल्क डेटासेट अपलोड फ्लो से मिलने वाले नियंत्रण से अधिक सूक्ष्म नियंत्रण चाहिए, तब इन ऑपरेशनों का उपयोग करें (जैसे: स्ट्रीम से एक-एक करके छवि अपलोड करना, बाद में एनोटेशन जोड़ना, या छवि मेटाडेटा और टैग अपडेट करना)। पूरे लेबल किए गए डेटासेट को एक साथ बल्क-इम्पोर्ट करने के लिए, देखें एक डेटासेट अपलोड करें.

HTTP API

एक छवि अपलोड करें

छवि को तीन तरीकों में से किसी एक से भेजें:

  • एक मल्टीपार्ट फ़ाइल अपलोड। स्थानीय फ़ाइलों के लिए यह सबसे कुशल विकल्प है।

  • पूरे अनुरोध बॉडी के रूप में एक base64 स्ट्रिंग। इसका उपयोग तब करें जब आपका क्लाइंट multipart अनुरोध नहीं बना सकता।

  • यह image एक सार्वजनिक URL के साथ query parameter। Roboflow छवि को अपने सर्वर से प्राप्त करता है, इसलिए बॉडी में कुछ भी नहीं भेजा जाता।

हर अपलोड एक image ID लौटाता है। इसका उपयोग छवि के लिए एनोटेशन अपलोड करने में करें। अपलोड की गई छवियाँ प्रोजेक्ट के Annotate पेज पर, Unassigned कॉलम में, आपके द्वारा नामित बैच में या "Uploaded via API" में दिखाई देती हैं।

Upload an image

post

Adds an image to the project and puts it in a batch. Send the image as a multipart file or a base64 body, or pass the image query parameter to have Roboflow fetch it from a URL. Uploading an image the project already has returns the existing image ID with duplicate set to true. Requires image:create. /{workspace}/{project}/upload works the same way.

Authorizations
AuthorizationstringRequired

Roboflow API key or OAuth access token.

Path parameters
projectstringRequired

Project URL slug.

Query parameters
imagestring · uriOptional

URL of an image for Roboflow to fetch and add. URL-encode it. Use it when you do not send the image in the body.

Example: https://i.imgur.com/PEEvqPN.png
namestringOptional

File name of the image. Roboflow infers it when you leave it out.

Example: dock-cam-001.jpg
splitstring · enumOptional

Split the image goes to.

Default: trainPossible values:
batchstringOptional

Name of the batch to add the image to. Without it, the image goes to the "Uploaded via API" batch.

Example: Warehouse cams
notesstring · max: 2000Optional

Note for the batch. The batch keeps the first note it gets. Annotation jobs made from the batch use it as their default instructions.

Example: Label every forklift, even when it is partly hidden.
tagstringOptional

Tag to add to the image. Repeat it to add more tags.

Example: night
metadatastringOptional

Custom metadata as a JSON object string. Keys use letters, numbers, underscores, and dots, and do not start with a dot. Keys that start with rf_internal are reserved.

Example: {"camera_id":"cam001"}
sequence_numberintegerOptional

Position of the image in a sequence. Use it to keep images in order.

sequence_sizeintegerOptional

Total number of images in the sequence.

Default: 100000
inference_idstringOptional

Inference ID from a Roboflow prediction. It links the image to that prediction in Model Monitoring.

Body
or
stringOptional

The whole body is the image encoded as base64. A data URL prefix (ex: data:image/jpeg;base64,) is allowed. Send every option as a query parameter.

Responses
200

Successful response.

application/json
successbooleanOptional

True when Roboflow added a new image.

duplicatebooleanOptional

True when the project already has this exact image. No new image is added, and id is the existing image.

idstringOptional

Image ID. Use it to upload an annotation for the image.

post/dataset/{project}/upload
POST /dataset/{project}/upload HTTP/1.1
Host: api.roboflow.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: multipart/form-data
Accept: */*
Content-Length: 134

{
  "file": "binary",
  "name": "dock-cam-001.jpg",
  "split": "train",
  "tag": "night",
  "metadata": "{\"camera_id\":\"cam001\",\"temperature\":72.5}"
}
{
  "success": true,
  "id": "YbNIgavTIk2xOOmJsHv5"
}

एक एनोटेशन अपलोड करें

पहले से अपलोड की गई किसी छवि के साथ एक एनोटेशन फ़ाइल संलग्न करें। यह किसी भी समर्थित एनोटेशन फ़ॉर्मैट के साथ काम करता है, जिसकी फ़ाइल छवि के फ़ाइल नाम को संदर्भित करती है। आप ऐप के Upload पेज पर अपनी छवियों के साथ एनोटेशन फ़ाइलें ड्रैग करके भी जोड़ सकते हैं।

डिफ़ॉल्ट रूप से एनोटेशन छवि को Dataset में जोड़ देता है, जिससे वह बैच, जॉब और समीक्षा फ्लो से बाहर हो जाती है। भेजें addToDataset=false ताकि छवि उस फ्लो में बनी रहे।

एक Action Recognition Project के लिए, एक roboflow-video-coco दस्तावेज़ छवि के स्थान पर वीडियो के segments के साथ भेजें, और image ID के स्थान पर video ID का उपयोग करें।

Upload an annotation

post

Saves an annotation file on an image that is already in the project. Roboflow reads the format from the name query parameter, so it works with any supported format whose file references the image's file name. By default the image is added to the Dataset, which takes it out of its batch, job, and review flow. In an Action Recognition project, pass a video ID as imageId and send a roboflow-video-coco document; prediction, predictionRouting, and jobName return 400 for videos. Requires image:annotate.

Authorizations
AuthorizationstringRequired

Roboflow API key or OAuth access token.

Path parameters
projectstringRequired

Project URL slug.

imageIdstringRequired

Image ID returned by the upload, or a video ID in an Action Recognition project.

Query parameters
namestringRequired

File name of the annotation file, with its extension. Roboflow reads the annotation format from it.

Example: dock-cam-001.xml
addToDatasetbooleanOptional

Add the image to the Dataset, so the next dataset version can include it. Send false to save the annotation and keep the image in its batch or job.

Default: true
splitstring · enumOptional

Split to set on the image. val and validation both mean valid. Leave it out to keep the image's split. A video added without a split goes to train.

Possible values:
overwritebooleanOptional

Replace an annotation the image already has. Without it the request fails with 409. Classification projects always replace.

Default: false
jobNamestringOptional

Move the image into the annotation job with this name, and create the job if it does not exist. Leave it out to keep the image where it is.

predictionbooleanOptional

Save the annotation as a model prediction instead of ground truth. A prediction never adds the image to the Dataset.

Default: false
predictionRoutingstring · enumOptional

Needs prediction=true and cannot be sent with jobName. review moves the image from its batch into a Review job, when the image is in a batch of this project and in no job. unassigned leaves batch and job membership alone.

Default: unassignedPossible values:
Body
stringOptional

The contents of the annotation file (ex: Pascal VOC XML, COCO JSON, YOLO TXT). For a single-label classification project, send the class name. For multi-label, send comma-separated class names, or a CSV with a header row of class names and one row of 0 and 1 values (set name to _classes.csv). For an Action Recognition project, send one roboflow-video-coco document.

Example: <annotation><filename>dock-cam-001.jpg</filename><object><name>forklift</name><bndbox><xmin>40</xmin><ymin>60</ymin><xmax>220</xmax><ymax>310</ymax></bndbox></object></annotation>
or
Responses
200

Successful response.

application/json
successbooleanOptional
warningsbooleanOptional

Present and true when some shapes were invalid and left out.

inDatasetbooleanOptional

Videos only. True when the video is in the Dataset after the save.

createdClassesstring[]Optional

Videos only. Classes the save added to the project.

post/dataset/{project}/annotate/{imageId}
POST /dataset/{project}/annotate/{imageId}?name=text HTTP/1.1
Host: api.roboflow.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: text/plain
Accept: */*
Content-Length: 181

"<annotation><filename>dock-cam-001.jpg</filename><object><name>forklift</name><bndbox><xmin>40</xmin><ymin>60</ymin><xmax>220</xmax><ymax>310</ymax></bndbox></object></annotation>"
{
  "success": true
}

एक छवि के बारे में विवरण प्राप्त करें

किसी छवि का फ़ाइल नाम, split, टैग, मेटाडेटा, एनोटेशन, और image URLs पढ़ें। किसी वीडियो के लिए, response में उसका poster image, एक अल्पकालिक download link, और उसके action segments.

Get image details

get

Returns an image's file name, split, tags, metadata, annotation, image URLs, and embedding. For a video, urls.original and urls.thumb hold its poster image, urls.video is a short-lived download link, segments lists its action segments, and annotation is null. Requires image:read.

Authorizations
AuthorizationstringRequired

Roboflow API key or OAuth access token.

Path parameters
workspacestringRequired

Workspace URL slug.

projectstringRequired

Project URL slug.

imageIdstringRequired

Image ID.

Query parameters
formatstringOptional

Return the annotation as a file in this export format (ex: voc, coco). Not supported for videos or with include.

Example: voc
includestring · enumOptional

Set to annotation to add the annotation group version, a signed image URL, and whether you can edit the annotation. Read annotationGroupVersion here before you save an annotation. You cannot use it with format.

Example: annotationPossible values:
Responses
200

Successful response.

application/json
get/{workspace}/{project}/images/{imageId}
GET /{workspace}/{project}/images/{imageId} HTTP/1.1
Host: api.roboflow.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "image": {
    "id": "YbNIgavTIk2xOOmJsHv5",
    "name": "dock-cam-001.jpg",
    "mediaType": "image",
    "annotation": {
      "key": "dock-cam-001.jpg",
      "width": 1280,
      "height": 720,
      "boxes": [
        {
          "label": "forklift",
          "x": 130,
          "y": 185,
          "width": 180,
          "height": 250
        }
      ]
    },
    "labels": null,
    "split": "train",
    "tags": [
      "night"
    ],
    "metadata": {
      "camera_id": "cam001"
    },
    "created": 1767225600000,
    "lastSet": 1767229200000,
    "urls": {
      "original": "https://source.roboflow.com/AbC123/YbNIgavTIk2xOOmJsHv5/original.jpg",
      "thumb": "https://source.roboflow.com/AbC123/YbNIgavTIk2xOOmJsHv5/thumb.jpg",
      "annotation": "https://source.roboflow.com/AbC123/YbNIgavTIk2xOOmJsHv5/annotation-forklifts.png"
    },
    "embedding": null
  }
}

Version Check के साथ एनोटेशन सहेजें

किसी छवि का एनोटेशन JSON shapes के साथ किसी और के संपादन को ओवरराइट किए बिना बदलें। पहले, छवि को include=annotationके साथ प्राप्त करें। फिर इसका annotationGroupVersion के रूप में expectedGroupVersionभेजें, भले ही छवि में कोई सहेजा हुआ एनोटेशन न हो। यदि आपने इसे पढ़ने के बाद एनोटेशन बदल गया है, तो save 409 स्थिति के साथ विफल हो जाता है। हर save अगली बार उपयोग करने के लिए नया version लौटाता है।

Save an image annotation with a version check

put

Replaces the project's annotation on one image. The save works only when expectedGroupVersion matches the current annotationGroupVersion, so it never overwrites an edit made by someone else. The API key needs the image:read and image:annotate scopes, and the member behind it needs permission to annotate.

Authorizations
AuthorizationstringRequired

Roboflow API key or OAuth access token.

Path parameters
workspacestringRequired

Workspace URL slug.

projectstringRequired

Project URL slug.

imageIdstringRequired

Image ID.

Body
groupstring · min: 1 · max: 200Required

The project's annotation group. Read it from the group field of the image response.

expectedGroupVersionintegerRequired

The annotationGroupVersion that GET returned. Send it even when the image has no saved annotation, because a cleared annotation keeps its version. Send 0 only when GET returns 0.

mutationIdstring · min: 1 · max: 128Required

A unique ID for this save.

isNullbooleanRequired

Set to true to mark the image as null (no objects). boxes must then be empty.

Responses
200

Successful response.

application/json
imageIdstringRequired
annotationGroupVersionintegerRequired

The new version. Send it as expectedGroupVersion on your next save. A save identical to the stored annotation returns the current version.

classesstring[]Required

The project's class names after the save.

put/{workspace}/{project}/images/{imageId}/annotation
PUT /{workspace}/{project}/images/{imageId}/annotation HTTP/1.1
Host: api.roboflow.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 284

{
  "group": "cats",
  "expectedGroupVersion": 0,
  "mutationId": "save-1",
  "annotation": {
    "boxes": [
      {
        "id": "1",
        "label": "cat",
        "x": 40,
        "y": 60,
        "width": 20,
        "height": 30
      },
      {
        "id": "2",
        "label": "cat",
        "type": "polygon",
        "x": 120,
        "y": 85,
        "width": 40,
        "height": 30,
        "points": [
          [
            100,
            70
          ],
          [
            140,
            70
          ],
          [
            120,
            100
          ]
        ]
      }
    ]
  },
  "isNull": false
}
{
  "imageId": "abc123",
  "annotationGroupVersion": 1,
  "classes": [
    "cat"
  ]
}

Dataset से एक छवि हटाएँ

ID के आधार पर प्रोजेक्ट से छवियाँ हटाएँ। जो छवि किसी और प्रोजेक्ट द्वारा उपयोग नहीं की जाती, वह स्थायी रूप से हटा दी जाती है।

Delete images from a project

delete

Removes images from the project. An image that no other project uses is deleted. IDs that are not in the project are skipped. Requires project:update.

Authorizations
AuthorizationstringRequired

Roboflow API key or OAuth access token.

Path parameters
workspacestringRequired

Workspace URL slug.

projectstringRequired

Project URL slug.

Body
imagesstring[] · min: 1Required

Image IDs to remove.

Responses
204

Completed with no response body.

No content

delete/{workspace}/{project}/images
DELETE /{workspace}/{project}/images HTTP/1.1
Host: api.roboflow.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 58

{
  "images": [
    "YbNIgavTIk2xOOmJsHv5",
    "pX2b7RkqLw9Zs3TnVc1d"
  ]
}

No content

छवि टैग जोड़ें और हटाएँ

किसी प्रोजेक्ट में एक छवि पर टैग जोड़ें, हटाएँ, या बदलें। आपको फ़ाइल नाम नहीं, image ID चाहिए: प्रोजेक्ट में खोजें इसे ढूँढने के लिए।

Add or remove image tags

post

Adds tags to an image, removes tags from it, or replaces all its tags. Use the image ID, not the file name: search the project to find an image's ID. Requires image:tag.

Authorizations
AuthorizationstringRequired

Roboflow API key or OAuth access token.

Path parameters
workspacestringRequired

Workspace URL slug.

projectstringRequired

Project URL slug.

imageIdstringRequired

Image ID.

Body
operationstring · enumRequired

add keeps the existing tags, remove deletes the listed tags, and set replaces every tag with the list.

Possible values:
tagsstring[]Required

Tags to add, remove, or set.

Responses
200

Successful response.

application/json
successbooleanOptional
post/{workspace}/{project}/images/{imageId}/tags
POST /{workspace}/{project}/images/{imageId}/tags HTTP/1.1
Host: api.roboflow.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 47

{
  "operation": "add",
  "tags": [
    "reviewed",
    "night"
  ]
}
{
  "success": true
}

छवि मेटाडेटा और टैग अपडेट करें

लिखें कस्टम मेटाडेटा और workspace में कहीं भी मौजूद छवियों पर टैग। एक छवि के लिए single-image endpoint का उपयोग करें। यह उत्तर देने से पहले परिवर्तन लागू करता है।

Update metadata and tags for one image

post

Sets and removes custom metadata and tags on one image, right away. The image can be in any project of the workspace. Requires image:tag.

Authorizations
AuthorizationstringRequired

Roboflow API key or OAuth access token.

Path parameters
workspacestringRequired

Workspace URL slug.

imageIdstringRequired

Image ID.

Body

Send at least one field. A key or tag cannot be both set and removed in one request. Keys use letters, numbers, underscores, and dots, and do not start with a dot. Keys that start with rf_internal are reserved.

removeMetadatastring[]Optional

Metadata keys to delete.

addTagsstring[]Optional

Tags to add.

removeTagsstring[]Optional

Tags to remove.

Responses
200

Successful response.

application/json
successbooleanOptional
post/{workspace}/images/{imageId}/metadata
POST /{workspace}/images/{imageId}/metadata HTTP/1.1
Host: api.roboflow.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 71

{
  "metadata": {
    "camera": "front",
    "blur_score": 0.8
  },
  "addTags": [
    "reviewed"
  ]
}
{
  "success": true
}

एक ही अनुरोध में अधिकतम 1,000 छवियाँ बदलने के लिए, batch endpoint का उपयोग करें। यह बैकग्राउंड में चलता है और एक task URL लौटाता है। इसे Async Tasks API के साथ poll करें जब तक task पूरा न हो जाए। इसका परिणाम सफल हुई छवियों की संख्या बताता है और विफल हुई छवियों की सूची देता है।

Update metadata and tags for multiple images

post

Sets and removes custom metadata and tags on up to 1,000 images in the background. Poll the returned task URL until it finishes. An image that is missing or in another workspace fails on its own and does not stop the others. Requires image:tag.

Authorizations
AuthorizationstringRequired

Roboflow API key or OAuth access token.

Path parameters
workspacestringRequired

Workspace URL slug.

Body
Responses
202

Accepted for asynchronous processing.

application/json
taskIdstringOptional

Asynchronous task ID.

urlstringOptional

URL to poll for the task status. The finished task's result lists totalProcessed, succeeded, failed, and failedItems.

post/{workspace}/images/metadata
POST /{workspace}/images/metadata HTTP/1.1
Host: api.roboflow.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 138

{
  "updates": [
    {
      "imageId": "abc123",
      "metadata": {
        "camera": "front"
      },
      "addTags": [
        "reviewed"
      ]
    },
    {
      "imageId": "def456",
      "removeTags": [
        "needs-review"
      ]
    }
  ]
}
{
  "taskId": "Qm9yZWFsVGFzazEyMw",
  "url": "https://api.roboflow.com/my-workspace/asynctasks/Qm9yZWFsVGFzazEyMw"
}

Python SDK

प्रोजेक्ट प्रति-छवि ऑपरेशनों को उपलब्ध कराता है जो bulk upload_dataset flow के पूरक हैं। इनका उपयोग तब करें जब आपको single-image uploads पर अधिक सूक्ष्म नियंत्रण चाहिए, बाद में एनोटेशन जोड़ना हो, या आप stream से एक-एक करके छवियाँ ingest कर रहे हों।

एक छवि अपलोड करें (वैकल्पिक एनोटेशन के साथ)

Project.upload() उच्च-स्तरीय "सही काम करो" सहायक है। यह एक अकेली छवि के साथ एक वैकल्पिक matching annotation file स्वीकार करता है और दोनों को एक ही कॉल में प्रोजेक्ट में भेज देता है।

single_upload() एक निम्न-स्तरीय संस्करण है जो वही arguments लेता है और image तथा (यदि प्रदान किया गया हो) annotation दोनों के लिए raw API responses लौटाता है।

केवल एक छवि अपलोड करें

जब एनोटेशन अभी मौजूद न हों और छवि सीधे किसी labeler के पास जाती हो, तब उपयोगी।

अपलोड करने से पहले एक छवि मान्य करें

check_valid_image() API को हिट किए बिना Roboflow की स्थानीय size / format जाँच चलाता है:

मौजूदा छवि से एक एनोटेशन संलग्न करें

save_annotation() पहले से प्रोजेक्ट में मौजूद किसी छवि पर एक एनोटेशन पोस्ट करता है। कहीं और बनाए गए labels जोड़ने, या model prediction को ground truth में बदलने के लिए उपयोगी।

भेजें annotation_labelmap="./labelmap.yaml" ताकि यदि आपके annotation format को आवश्यकता हो तो class indices को class names में मैप किया जा सके।

के साथ सहेजना is_prediction=True छवि को review job में ले जा सकता है। देखें जहाँ predictions पहुँचते हैं.

किसी छवि का मेटाडेटा प्राप्त करें

छवि का मेटाडेटा, वर्तमान split, और annotation status लौटाता है।

छवियाँ हटाएँ

प्रोजेक्ट-स्तर (केवल इस प्रोजेक्ट से संबंधित छवियाँ हटाता है):

वर्कस्पेस-स्तर (यह देखे बिना छवियाँ हटाता है कि कौन-से प्रोजेक्ट उन्हें संदर्भित करते हैं - सावधानी से उपयोग करें):

v1.3.6+ में अपलोड्स पर एक नोट

के अनुसार roboflow 1.3.6, SDK Pillow के माध्यम से दोबारा encode करने के बजाय मूल image bytes अपलोड करता है। यह वेब uploader के साथ समानता बहाल करता है और Roboflow सर्वर को SHA-256 द्वारा uploads deduplicate करने देता है। यदि आपके पास ऐसा automation है जो एक ही छवि को दो बार अपलोड करता है (उदाहरण के लिए उसे कई batches में जोड़ने के लिए), तो आप देखेंगे कि दूसरा upload अतिरिक्त storage credits खर्च किए बिना सफल हो जाता है।

CLI

CLI का उपयोग करके एक छवि और उसका वैकल्पिक annotation, टैग, या metadata अपलोड करें।

विकल्प

फ़्लैग
विवरण

-p, --project

प्रोजेक्ट आईडी (आवश्यक)

-a, --annotation

एक annotation file का path

-m, --labelmap

एक label map file का path

-s, --split

Dataset split: train, valid, या test. डिफ़ॉल्ट है train.

-t, --tag

कॉमा से अलग किए गए tag names

-M, --metadata

JSON string के रूप में metadata

--is-prediction

अपलोड को prediction के रूप में चिह्नित करें

-b, --batch

Batch name

उदाहरण

एक annotation के साथ छवि अपलोड करें:

tags और metadata के साथ छवि अपलोड करें:

किसी directory या .zip archive को अपलोड करने के लिए, देखें एक डेटासेट अपलोड करें.

MCP सर्वर

अपने AI एजेंट को इससे कनेक्ट करें MCP सर्वर और यह इन टूल्स से छवियों को ढूँढकर अपडेट कर सकता है:

टूल
विवरण

images_search

किसी प्रोजेक्ट के अंदर छवियाँ खोजें।

images_update_metadata

एकल छवि पर मेटाडेटा और टैग अपडेट करें।

images_batch_update_metadata

कई छवियों पर मेटाडेटा और टैग का बैच-अपडेट करें।

annotations_save

मौजूदा छवि के लिए एक annotation सहेजें।

अंतिम अपडेट

क्या यह उपयोगी था?