Coder Social home page Coder Social logo

Comments (7)

alexheat avatar alexheat commented on May 20, 2024

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.

ytzeng1 avatar ytzeng1 commented on May 20, 2024

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.

  1. detectron expect 1-indexed category id (not sure if all coco requires this) while as yolo has class id 0-indexed.
  2. Yolo label does not have iscrowd property so after exporting to COCO the iscrowd 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.

alexheat avatar alexheat commented on May 20, 2024

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.

ytzeng1 avatar ytzeng1 commented on May 20, 2024

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.

alexheat avatar alexheat commented on May 20, 2024

@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.

alexheat avatar alexheat commented on May 20, 2024

@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.

alexheat avatar alexheat commented on May 20, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.