GithubHelp home page GithubHelp logo

Comments (3)

loomcode avatar loomcode commented on June 6, 2024

Taking an example from Detectron2, I added a polygon friendly version of your "convert_to_coco" function by making some minor changes to the bounding box loop:

            for bbox in bboxes:

                category_name = bbox['polygonlabels'][0]

                if category_name not in category_name_to_id:
                    category_id = len(categories)
                    category_name_to_id[category_name] = category_id
                    categories.append({
                        'id': category_id,
                        'name': category_name
                    })
                category_id = category_name_to_id[category_name]
                annotation_id = len(annotations)

                **poly = [(x + 0.5, y + 0.5) for x, y in bbox['points']]
                pxpy = np.array(poly)
                poly = [p for x in poly for p in x]
                

                annotations.append({
                    'id': annotation_id,
                    'image_id': image_id,
                    'category_id': category_id,
                    'segmentation': [poly],
                    'bbox': [np.min(pxpy[:,0]), np.min(pxpy[:,1]), np.max(pxpy[:,0]), np.max(pxpy[:,1])],
                    'ignore': 0,
                    'iscrowd': 0
                })**

Note, that I changed the bbox boundaries to absolute coords and imported numpy. It runs but I still need to check if the output works with a model.

from label-studio-converter.

makseq avatar makseq commented on June 6, 2024

HumanSignal/label-studio#410

from label-studio-converter.

niklub avatar niklub commented on June 6, 2024

@loomcode ,
This functionality has been added since label-studio>=0.7.5. Can you try it out and close an issue if everything is OK ?

from label-studio-converter.

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.