इमेजें प्रबंधित करें
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" में दिखाई देती हैं।
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.
Roboflow API key or OAuth access token.
Project URL slug.
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.
https://i.imgur.com/PEEvqPN.pngFile name of the image. Roboflow infers it when you leave it out.
dock-cam-001.jpgSplit the image goes to.
trainPossible values: Name of the batch to add the image to. Without it, the image goes to the "Uploaded via API" batch.
Warehouse camsNote for the batch. The batch keeps the first note it gets. Annotation jobs made from the batch use it as their default instructions.
Label every forklift, even when it is partly hidden.Tag to add to the image. Repeat it to add more tags.
nightCustom 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.
{"camera_id":"cam001"}Position of the image in a sequence. Use it to keep images in order.
Total number of images in the sequence.
100000Inference ID from a Roboflow prediction. It links the image to that prediction in Model Monitoring.
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.
Successful response.
True when Roboflow added a new image.
True when the project already has this exact image. No new image is added, and id is the existing image.
Image ID. Use it to upload an annotation for the image.
No image was sent, the image is too large or not readable, metadata or notes is invalid, or Roboflow could not fetch the image URL (bad URL, private address, or a 4xx answer from the host). A failed fetch has a message that starts with "Could not fetch image URL".
Authentication is missing or invalid.
The credential does not have access to this resource.
The resource does not exist or is not accessible.
The request rate is too high.
The host of the image URL answered with a 5xx status or the connection failed. The response sets retryable to true, so send the same request again later.
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 का उपयोग करें।
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.
Roboflow API key or OAuth access token.
Project URL slug.
Image ID returned by the upload, or a video ID in an Action Recognition project.
File name of the annotation file, with its extension. Roboflow reads the annotation format from it.
dock-cam-001.xmlAdd 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.
trueSplit 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.
Replace an annotation the image already has. Without it the request fails with 409. Classification projects always replace.
falseMove 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.
Save the annotation as a model prediction instead of ground truth. A prediction never adds the image to the Dataset.
falseNeeds 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.
unassignedPossible values: 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.
<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>Successful response.
Present and true when some shapes were invalid and left out.
Videos only. True when the video is in the Dataset after the save.
Videos only. Classes the save added to the project.
Roboflow could not parse the annotation or match it to the image, every shape is invalid, a classification file names no class, a label is too long, or predictionRouting is invalid or sent without prediction=true or with jobName.
Authentication is missing or invalid.
The credential does not have access to this resource.
The resource does not exist or is not accessible.
The image already has an annotation. Send overwrite=true to replace it.
The request rate is too high.
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.
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.
Roboflow API key or OAuth access token.
Workspace URL slug.
Project URL slug.
Image ID.
Return the annotation as a file in this export format (ex: voc, coco). Not supported for videos or with include.
vocSet 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.
annotationPossible values: Successful response.
format was sent for a video or together with include=annotation.
Authentication is missing or invalid.
The credential does not have access to this resource.
The image does not exist, belongs to another workspace, or is not in this project.
The request rate is too high.
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 लौटाता है।
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.
Roboflow API key or OAuth access token.
Workspace URL slug.
Project URL slug.
Image ID.
The project's annotation group. Read it from the group field of the image response.
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.
A unique ID for this save.
Set to true to mark the image as null (no objects). boxes must then be empty.
Successful response.
The new version. Send it as expectedGroupVersion on your next save. A save identical to the stored annotation returns the current version.
The project's class names after the save.
The request body is invalid, the group does not match the project, or this image or annotation type cannot be edited.
Authentication is missing or invalid.
The credential does not have access to this resource.
The project or image is missing, or the API key cannot write to it.
The annotation changed since you read it, the save was busy, or the project has locked classes and a label is not one of them. Read the image again and retry.
The request rate is too high.
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 के आधार पर प्रोजेक्ट से छवियाँ हटाएँ। जो छवि किसी और प्रोजेक्ट द्वारा उपयोग नहीं की जाती, वह स्थायी रूप से हटा दी जाती है।
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.
Roboflow API key or OAuth access token.
Workspace URL slug.
Project URL slug.
Image IDs to remove.
Completed with no response body.
No content
images is empty.
Authentication is missing or invalid.
The project belongs to another workspace, or deletions are paused because too many destructive actions ran in a short time.
The resource does not exist or is not accessible.
The request rate is too high.
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 चाहिए: प्रोजेक्ट में खोजें इसे ढूँढने के लिए।
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.
Roboflow API key or OAuth access token.
Workspace URL slug.
Project URL slug.
Image ID.
add keeps the existing tags, remove deletes the listed tags, and set replaces every tag with the list.
Tags to add, remove, or set.
Successful response.
operation is not add, remove, or set, or tags is missing, not an array, or holds an invalid tag.
Authentication is missing or invalid.
The credential does not have access to this resource.
The image does not exist, belongs to another workspace, or is not in this project.
The request rate is too high.
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 का उपयोग करें। यह उत्तर देने से पहले परिवर्तन लागू करता है।
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.
Roboflow API key or OAuth access token.
Workspace URL slug.
Image ID.
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.
Metadata keys to delete.
Tags to add.
Tags to remove.
Successful response.
The body is empty, a field has the wrong type, a key or tag is invalid, or the same key or tag is both set and removed.
Authentication is missing or invalid.
The credential does not have access to this resource.
The image does not exist or belongs to another workspace.
The request rate is too high.
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 पूरा न हो जाए। इसका परिणाम सफल हुई छवियों की संख्या बताता है और विफल हुई छवियों की सूची देता है।
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.
Roboflow API key or OAuth access token.
Workspace URL slug.
Accepted for asynchronous processing.
Asynchronous task ID.
URL to poll for the task status. The finished task's result lists totalProcessed, succeeded, failed, and failedItems.
updates is empty or has more than 1,000 entries, an image ID is listed twice, or an entry is invalid.
Authentication is missing or invalid.
The credential does not have access to this resource.
The resource does not exist or is not accessible.
The request rate is too high.
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 सहेजें।
अंतिम अपडेट
क्या यह उपयोगी था?