Comments (7)
Hi @ytzeng1 , thank you for letting us know. Sounds like an easy fix for us to make. Would you be able to share your code or another sample that uses detectron so we can validate the fix?
from pylabel.
Hi @alexheat
Thanks for your quick reply. I am converting a dataset from YOLOv5 to COCO for detectron2, during troubleshooting, I also noticed that a few other minor things that prevent detectron from registering the dataset.
- detectron expect 1-indexed category id (not sure if all coco requires this) while as yolo has class id 0-indexed.
- Yolo label does not have
iscrowd
property so after exporting to COCO theiscrowd
field is null which also confuses detectron.
All are minor problems and should be easy to fix. I curated a toy dataset for you to validate
ballons.zip
It includes the code snippet and an expected json format. Thanks!
from pylabel.
thank you @ytzeng1 ! I didn't know that detection required 1-index dataset. I knew that Yolo requires 0 index dataset, which also causes some problems.
Converting datasets is not as easy as it seems :)
I think for the iscrowd issue, I will make the default for iscrowd to be 0 (even for null values)
For the indexing issues I would like to get your feedback on the best solution. Here are some options I thought of:
- Add an optional parameter to the exporter called "FirstCatd" or something like that.
- If the value is 0, then it will check the lowest value and if it is 0 it won't make any change. but if it is 1 it substract 1 from all of the category ids to make it zero indexed
- If the value is 1, then it will check the lowest value and if it is 1 it won't change anything, but if it is 0 it will add 1 to all of the category ids to make it 1 indexed.
- Similar to the above call the parameter ReindexCatId and the user can pass a value of 0 or 1. If they chose 0 for example it will make sure that the class ids start at 0 and then are sequential from 0,1,2,3,4 etc. If the value is 1 then it will make them all sequential from 1 (1,2,3,4,5).
- Similar to the above but instead of being a parameter of the export function, it is a command that needs to be done before exporting the dataset. This seems more clean to me, but people might not discover the option as easily.
from pylabel.
Hi @alexheat ,
Thank you for providing all these possible solutions. Personally I'm fine with all your proposals. Currently I am using your third suggestion,
dataset.df['cat_id'] = dataset.df['cat_id'].astype('int') + 1
dataset.df['ann_iscrowd'] = dataset.df['ann_iscrowd'].fillna(0)
Something like this could be documented in your notebook for users to discover more easily.
In terms of modifying the export function, how about adding a parameter called format_ids
. If set to true, the function would map id
to the range [1, NUM_CLASSES]
. For example, if users are working on a subset of data, the categories might not be continuous and then some libraries would complain..., or better yet, the users can specify a range where they want their ids
to be mapped to. Thanks again!
from pylabel.
@ytzeng1 , I have released a new version of the package that address the first issue you mentioned https://github.com/pylabel-project/pylabel/releases/tag/v0.1.20
If you have time please give it a try and confirm that it works as expected.
I will try to work on the other issues later this week.
from pylabel.
@ytzeng1 I also like your idea to add the documentation of your +1 trick to the notebook. If you want to try and make a contribution you could try to form the sample notebooks https://github.com/pylabel-project/samples and then make your change and then make a pull request and we can take your change.
(Or I will add it next time I update the notebook.)
from pylabel.
@ytzeng1 I have added your tip to the notebook at https://github.com/pylabel-project/samples/blob/main/yolo2coco.ipynb
All of the annotations are stored in a Pandas dataframe that you can access directly as 'dataset.df'. Not only can you do your own custom queries of the dataset, but you can also manipulate the dataset by removing rows, changing labels, etc.
For example, YOLO class ids start at 0 but some frameworks that use COCO require the class ids to start at 1. You can easily reindex the class ids before you export them using a line like this.
dataset.df['cat_id'] = dataset.df['cat_id'].astype('int') + 1
Thank you again for your help. If you have any other ideas please let us know.
from pylabel.
Related Issues (20)
- Crash when converting an image from COCO to YOLO that has no annotation in it HOT 1
- AttributeError: 'DataFrame' object has no attribute 'append' HOT 4
- is CreateML json format supported? HOT 5
- Error when i transform a COCO dataset to a YOLO dataset with segmentation = true and cat_id_index = 0 HOT 3
- It's possible to import YOLO segmentation dataset? HOT 2
- Annotation ids in '/content/test/img/coco128.json' are not unique! HOT 1
- StratifiedGroupShuffleSplit results in Empty DataFrame HOT 3
- yolo class label is unsorted HOT 1
- cat_id_index for yolov5 to coco format HOT 1
- how to edit yolo label with imported txt labels ? HOT 1
- UnboundLocalError: local variable 'categories' referenced before assignment HOT 2
- how to split YOLO datasets to train/val. Not train/val/test HOT 1
- Verbosity or progress bar HOT 5
- AssertionError: Output shape does not match input shape. Data loss has occured. HOT 4
- ShowClassSplits returning empty dataframe for YoloV5
- Class categories not correct after conversion from coco to yolo format. HOT 3
- Add tqdm to setup.py HOT 2
- Update Readme examples HOT 1
- Issue using both segmentation=True and cat_id_index=0 HOT 2
- YOLOv5 class index starts from 1 HOT 4
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 pylabel.