Comments (1)
To avoid problems, the best is to create a script to remap your categories id once you have exported annotations.
Here is what a chatgpt tool like say to do (I don't have tested it, but it seem's ok):
To remap categories in a COCO annotation file using a Python script, you can follow these steps:
Install the required dependencies:
pip install pycocotools
Import the necessary libraries:
from pycocotools.coco import COCO
import json
Load the COCO annotation file:
annotation_file = 'path/to/annotation_file.json'
coco = COCO(annotation_file)
Define the mapping of old category IDs to new category IDs:
category_mapping = {
1: 10,
2: 20,
3: 30,
# add more mappings as needed
}
Create a new category list with remapped IDs:
new_categories = []
for old_cat_id, new_cat_id in category_mapping.items():
old_cat = coco.loadCats(old_cat_id)[0]
new_cat = old_cat.copy()
new_cat['id'] = new_cat_id
new_categories.append(new_cat)
Update the category list in the COCO annotation file:
coco.dataset['categories'] = new_categories
Update the category IDs in the annotation data:
for annotation in coco.dataset['annotations']:
old_cat_id = annotation['category_id']
new_cat_id = category_mapping.get(old_cat_id)
if new_cat_id:
annotation['category_id'] = new_cat_id
Save the updated annotation file:
remapped_annotation_file = 'path/to/remapped_annotation_file.json'
with open(remapped_annotation_file, 'w') as f:
json.dump(coco.dataset, f)
That's it! The resulting COCO annotation file with remapped categories will be saved as remapped_annotation_file.json. Make sure to replace 'path/to/annotation_file.json' and 'path/to/remapped_annotation_file.json' with the actual file paths.
Please note that this script assumes that the COCO annotation file follows the standard COCO format.
from coco-annotator.
Related Issues (20)
- Trouble with 16 bit geryscale image HOT 1
- Automation of annotation HOT 5
- lost annotations and images in file directory
- .json file of image dataset annotations
- Keyboard shortcuts not working HOT 4
- Visibility not work! HOT 6
- ADDING KEYPOINTS FAILS EVERYTIME!!!!!!!!! HOT 1
- When use Eraser tool, docker server sometimes shows error HOT 4
- Sever stopped when trying to read next pic/annotation data faster with multiple click on next arrow or multiple push on N key
- coco-annotator docker container loops while booting up ==> [ERROR/MainProcess] consumer: Cannot connect to amqp://user:**@messageq:5672//: timed out. HOT 2
- When copy images to dataset directory, Thumbnail doesn't work.
- dataset collected with coco-annotator HOT 1
- [Help] Proxy problem search for helps HOT 1
- How many instances could make from one category? HOT 1
- Why the coco-annotator I installed doesn't have delete option? HOT 22
- API access for beginners
- COCO Annotator Next Generation HOT 2
- Convert keypoint format to coco dataset format HOT 1
- why errno 19 frequently shows up
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coco-annotator.