ashnair1 / coco-assistant Goto Github PK
View Code? Open in Web Editor NEWHelper for dealing with MS-COCO annotations
Home Page: https://ashnair1.github.io/COCO-Assistant
License: MIT License
Helper for dealing with MS-COCO annotations
Home Page: https://ashnair1.github.io/COCO-Assistant
License: MIT License
I am wondering what happens when I want to merge two coco sets having different category list in their respective "categories" fields. Can COCO-Assistant handle that scenario?
Bests
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
Thank you
@ashnair1 ashnair1
I am using Google colab, while using
cas.ann_stats(stat="cat", arearng=None, show_count=False, save=False)
arearng=None, I did not understand what should be the arearng, I want complete distribution of categories from my COCO json file.
Please Help, Thanks.
Training certain networks using transfer learning for segmentation leads to lots of false positives. One method is to feed negative or background images to the network.
The ability for coco assistant to help merge negative samples would be a good feature to my understanding.
Hi @ashnair1 ,
Thanks for sharing.
Does this code work for merging two sets (training, validation) of the same dataset, with segmentation is in RLE?
Thanks for the great tool. I have two questions about multiple dataset merging:
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.
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?
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
I tried merging 3 JSON files using the coco-assistant and when using on my training code ran through this error. How do I ensure the annotation ids are different when merging?
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?
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_id
s 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,
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
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, when i run merge command, "cas.merge(merge_images=True) ",
i got the error-
TypeError: merge() got an unexpected keyword argument 'merge_images'
Any suggestions?
Thanks.
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
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
This is beneficial for two reasons:
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.
Hi @ashnair1 ,
I want to crop the large image into several small images and retain the annotation mapping. Can you give me advice?
pathlib
allows easier handling of suffixes (and paths in general). It's a better alternative
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
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?
Leverage CircleCI to automate the release process
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
Google style docstrings to be added
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.