Giter Site home page Giter Site logo

ashnair1 / coco-assistant Goto Github PK

View Code? Open in Web Editor NEW
91.0 91.0 33.0 12.63 MB

Helper for dealing with MS-COCO annotations

Home Page: https://ashnair1.github.io/COCO-Assistant

License: MIT License

Python 100.00%
annotation-processor ms-coco object-detection

coco-assistant's People

Contributors

ashnair1 avatar dependabot[bot] avatar imgbotapp avatar khizar-anjum avatar lplenka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

coco-assistant's Issues

merging dataset

image
i don't know what happen when i try to merge datasets together.

Incorrect id and image_id after merging

Hey,
I was merging 2 json files, one file image_id starts from 600 to 999. second one has image_id from 000 to 399.

After merging the 2 files, the image id for the first file (600 to 999) is generated correctly.
However, for the second file, the image_ids are wrong. for example, for image_id 399, the generated id is 601 and it follows till 900

Becoz of this, the number of samples for me is reduced to 401 which in reality after merging should be at least over 600.

Could you tell me why is this the case?? how can I resolve this?

Note: I did direct installation using pip install coco-assistant for python 3.6

I have added two snippets
file 2
file 1

Thank you

merging dataset only supports ".png", ".jpg" format?

Thanks for the great tool. I have two questions about multiple dataset merging:

  1. does merging dataset function only support ".png", ".jpg" format? I found the following codes
if merge_images:
            print("Merging image dirs")
            im_dirs = [os.path.join(self.img_dir, folder) for folder in self.imgfolders]
            imext = [".png", ".jpg"]
for imdir in tqdm(im_dirs):
                ims = [i for i in os.listdir(imdir) if i[-4:].lower() in imext]
                for im in ims:
                    shutil.copyfile(os.path.join(imdir, im), os.path.join(self.resim_dir, im))

different datasets to be merged should not contain images which have the same name? for example, I have 2 datasets: A_dataset, B_dataset. in A_dataset I have an image named 1.jpg. and in B_dataset I also have an image named 1.jpg. then what will happen for this case?

thank you so much.

Assertion Error

I'm getting 'raise AssertionError("Image dir and corresponding json file must have the same name")

This is my structure from the tree command:

.
├── annotations
│   ├── train.json
│   └── val.json
└── images
    ├── train [118287 entries exceeds filelimit, not opening dir]
    └── val [5000 entries exceeds filelimit, not opening dir]

From python in that directory I'm running:

from coco_assistant import COCO_Assistant
import os

img_dir = os.path.join(os.getcwd(), 'images')
ann_dir = os.path.join(os.getcwd(), 'annotations')

cas = COCO_Assistant(img_dir, ann_dir)

I can't see how the paths do not match?

Merging more than 2 annotations

Hi
Thank you for the code!
Is it possible to merge multiple coco annotations into 1 file?
In my case 15K json files.

Thanks in advance

Merging Datasets

Hello, I'd like to have more of an idea of what happens when I merge 2 or more datasets. I currently have 3 datasets (3 annotations files and 3 folders of images): the images are all labeled from 0 to n with n being the total number of images.

Do I have to rename the images for the merging to work?

The first image ID can be a middle number in a merged JSON file

Hello.

As mentioned in #64 (comment), the first image_id in a merged JSON file get higher if it starts from a middle number defined in the first given file.
Since image_ids in the second file will be rewritten to new numbers, it may not need to keep those middle number any longer.
In other words, there is an approach to start image_id from a base number (e.g. 0 as default).

Please kindly consider this matter. Now I interested to contribute.

Regards,

Background option

By default background (in segmentation masks) is assumed to be 0. However other frameworks like detectron2 expects background to be the last index i.e. if there are n classes, background should be n+1. Would be a nice option to have

give list of classes to remove

hi,
you have done a very useful tool. it would be very good to provide directly the list of classes to remove at once, like
['car','boat'] instead of manual loop.

or on the opposite, if we could provide just the list of classes we want to keep. would be very useful!

Hi, how can I merge it for multiple dataset??

Hi, I am trying to merge the multiple images with coco json format.
And, I could find your github page seems like very nice.

My question is that I have a dataset. and each image with each json file (coco format).
In this case, how can I use your set (an example is below?
If a picture or video such as youtube for easily understanding your nice code exists, it will be better.

Thank you.

images
      -abc1.tiff
      -abc2.tiff
      -abc3.tiff
      -abc4.tiff

annotations
      -abc1.json
      -abc2.json
      -abc3.json
      -abc4.json

Related Work

I've been working on a coco helper library called kwcoco for the past few years, and I'm currently building up a list of related work (including this repo) and adding references to them on the kwcoco README.

This is just a friendly FYI that this tool exists and may be useful for you: https://github.com/Kitware/kwcoco

Add feature: create tiny coco datasets

This is beneficial for two reasons:

  1. Ability to create tiny coco datasets is useful for debugging and provides a useful reference for the MS COCO spec.
  2. Won't need to download testing data from google drive

image_ids and ann_ids are not sorted

Your code to get last image_id and last ann_id:

                last_imid = cann["images"][-1]["id"]
                last_annid = cann["annotations"][-1]["id"]

Based on your code i think you assume that image_ids and ann_ids are sorted which is not the case with coco annotations.

merge two MOTChallenge datasets

Hello Sir,

thank you for your contribution!

as the title states, I want to merge two MOTChallenge datasets which are in coco format. My question is that does your merge script support to merge "track_id" keyvalue as well?

Thank you

How should we use this package??

I have multiple directories and in each directory there exists a dataset with coco format.
I just found this package but I do not have any tutorial on how to use it?

can u please help me guys?

JPEG images are not merged while merging different coco dataset

Hello

Thank you for your amazing work.

I have checked issue20

I have noticed the below code where you give png, jpg, and jpeg in coco_assistant.py is been updated

if merge_images:
         print("Merging image dirs")
         im_dirs = self.imgfolders
         imext = [".png", ".jpg", ".jpeg"]

I have tried installing the coco_assistant using

pip install coco-assistant
import os
from coco_assistant import COCO_Assistant

# Specify image and annotation directories
img_dir = os.path.join(os.getcwd(), 'images')
ann_dir = os.path.join(os.getcwd(), 'annot')

# Create COCO_Assistant object
# cas = COCO_Assistant(img_dir, ann_dir)
cas = COCO_Assistant(img_dir, ann_dir)
cas.merge(merge_images=True)

My dataset is having JPEG and JPG images.
While Doing this I can merge JPG images but not JPEG in merged images
but in annotations this JPEG file is present.

I do not know why.
Can you give any insights? It will be very helpful

Detection to Segmentation mask issue

The current way det2seg works is by iterating over the class masks and taking the max. This introduces a problem in areas where categories overlap since only the category with the highest category_id is kept. The problem can be seen in the following image:

mask_issue

Error with visualization

Hi,
Thanks for your library, it is very useful.
When trying the visualization mode, I get the following error:

Traceback (most recent call last):
File ".../site-packages/matplotlib/cbook/init.py", line 216, in process
func(*args, **kwargs)
File ".../site-packages/matplotlib/widgets.py", line 220, in _release
func(event)
File ".../site-packages/coco_assistant/coco_visualiser.py", line 79, in forward
self.set_val(i)
File ".../site-packages/matplotlib/widgets.py", line 466, in set_val
func(val)
File ".../site-packages/coco_assistant/coco_visualiser.py", line 153, in update
ann.showAnns(img_anns, ax=ax)
TypeError: showAnns() got an unexpected keyword argument 'ax'
Traceback (most recent call last):
File ".../site-packages/matplotlib/cbook/init.py", line 216, in process
func(*args, **kwargs)
File ".../site-packages/matplotlib/widgets.py", line 220, in _release
func(event)
File ".../site-packages/coco_assistant/coco_visualiser.py", line 79, in forward
self.set_val(i)
File ".../site-packages/matplotlib/widgets.py", line 466, in set_val
func(val)
File ".../site-packages/coco_assistant/coco_visualiser.py", line 153, in update
ann.showAnns(img_anns, ax=ax)
TypeError: showAnns() got an unexpected keyword argument 'ax'
Traceback (most recent call last):
File ".../site-packages/matplotlib/cbook/init.py", line 216, in process
func(*args, **kwargs)
File ".../site-packages/matplotlib/widgets.py", line 220, in _release
func(event)
File ".../site-packages/coco_assistant/coco_visualiser.py", line 79, in forward
self.set_val(i)
File ".../site-packages/matplotlib/widgets.py", line 466, in set_val
func(val)
File ".../site-packages/coco_assistant/coco_visualiser.py", line 153, in update
ann.showAnns(img_anns, ax=ax)
TypeError: showAnns() got an unexpected keyword argument 'ax'

Thanks

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.