-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Augmenting only some classes in instance segmentation dataset that was annotated using the COCO format #7
Comments
Hi, I am not sure if I understand what you are trying to do. Do you want to ignore images containing the other classes? What happens if an image contains classes that you are interested in and classes that you want to ignore? Could you provide a small example showing what you want to do? Best, |
Hi thanks for your reply. Assume I have a dataset of images that have 4 classes, each class consists of images ( see the attached figure). And I want to augment images in only three classes (in my case, class 1,2, & 4). Also, assume that data is annotated COCO format ( JSON like). In COCO formatted data, there are categories, IDs, and names specified for each class. So is there a way to exclude images of one class/category/ from augmenting. |
Hi, Just checking, your images containing class 4 do not contain class 3, do they? In any case, that feature is not available in CLoDSa, so feel free to implement it and let me know if you need help. I can also implement it by myself, but it can take me some time. Best. |
@joheras thanks, Yes, of course, I am assuming images containing class 3 to not be in other classes. Anyhow, thanks. |
Ok, I think that I might have a new version of the library including such a feature by the end of the week. |
Okay thanks, I will leave it for you then... the reason I highlighted to you is; this could help solve the problem of unbalanced data. which causes models to overfit to overly-represented classes. this can also solve a lot of industrial problems where it is difficult to acquire images from some classes. so it is worth implementing. and let me know if you need any assistance in this. |
I think that the new functionality is ready, you can find it if you update clodsa to the version 1.2.33. There is a notebook explaining the new functionality in: You can also run it in Colab: Let me know if that was what you were thinking about. |
Great work, I was also reading your code. specifically the one for coco format annotation. And I realized you are using "cv2.findContours". But sometimes., some images might have small contours (as in my case.. e.g. very small bacteria shapes) which might be difficult for "cv2.findContours" to extract or get contours. which then leads the code to throw errors. So, in such cases skipping that image would be okay, and that is what I am doing now. When I finish I will send a pull request for modifications so that someone else doesn't get frustrated with such errors. |
Great. Thanks. |
I have tried the COCO augmentation, but I am facing a problem that I can figure out so far. when I try to ignore such masks that have "None" contours the saved "annotation" file doesn't contain annotations of the new augmented images. In other words, images are augmented correctly but the annotation array in the generated coco file is empty. please let me know if you have encountered such a problem. Thanks |
I have not encountered such a problem. Could you send me a small dataset where I can reproduce the problem? Best |
In order to reproduce the issue. Could you tell me the class that you ignore and the augmentation techniques that you are using? If you are using a Jupyter notebook for the augmentation process, it would be easier if you send it to me. |
Hi @joheras I modified the "cocoLinearInstanceSegmentationAugmentor.py" such that it runs when 'cnts' is empty. the small change I made that ran for me is below:
Also, I have attached a zip file containing the jupyter notebook, outputted images, and annotations. If you open the annotation file, you can see that the 'annotation' list at the end is empty. In the modified script, I only added try/except. using "if cnts is not None:" produces another problem anyhow, all the problem arises from finding contours..... |
You have not added the zip file. |
can you refresh the page once more |
Now, I see it. I will check this issue tomorrow and let you know. |
Great.... Thanks. |
I think that I have fixed the problem. Could you check whether the attached file is the correct result? The fixed version is in GitHub and also can be installed via pip |
Thanks let me check |
_RemoteTraceback Traceback (most recent call last) The above exception was the direct cause of the following exception: TypeError Traceback (most recent call last) ~/miniconda3/envs/logo-detection/lib/python3.7/site-packages/clodsa/augmentors/cocoLinearInstanceSegmentationAugmentor.py in applyAugmentation(self) ~/miniconda3/envs/logo-detection/lib/python3.7/site-packages/joblib/parallel.py in call(self, iterable) ~/miniconda3/envs/logo-detection/lib/python3.7/site-packages/joblib/parallel.py in retrieve(self) ~/miniconda3/envs/logo-detection/lib/python3.7/site-packages/joblib/_parallel_backends.py in wrap_future_result(future, timeout) ~/miniconda3/envs/logo-detection/lib/python3.7/concurrent/futures/_base.py in result(self, timeout) ~/miniconda3/envs/logo-detection/lib/python3.7/concurrent/futures/_base.py in __get_result(self) TypeError: object of type 'NoneType' has no len() I don't know what you have done, but with the same data and jupyter notebook, I am getting that error. which is clear. I tried to put another "If statement" to skip when the cnts is 'None', but then I get the below error """ |
Is the same dataset that you sent me previously? I am not able to reproduce such error. |
yes, the same data, and the same jupyter code I sent you yesterday.... can we check together if you are available now. |
As far as I understood, you added this line of code. which I have already tried before. len(cnts)>0: |
Yes. That os correct. Are you using the new version of clodsa or have you
modify the code?
El mar., 3 sept. 2019 17:52, Jama Hussein Mohamud <[email protected]>
escribió:
… As far as I understood, you added this line of code. which I have already
tried before.
len(cnts)>0:
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7?email_source=notifications&email_token=ABJRAG3A76UES6I4LACMMHTQH2B3PA5CNFSM4IQ2HJDKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5YVGDI#issuecomment-527520525>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABJRAGYO2KGN36KIZRP7FZLQH2B3PANCNFSM4IQ2HJDA>
.
|
Of course, I have used the modified one. but the error persists |
Hi, Could it be an issue related to your version of OpenCV? It seems that it works fine with version 3.4 of OpenCV, but maybe you are using a different version. |
Hi, Let me check the version of OpenCV Thanks |
I am using OpenCV version '4.1.0'. Do you think this is the problem? I will downgrade, and get back to you if the problem still persists. |
I check in colab by installing the last version of OpenCV (4.1.1) and I am
able to reproduce the problem. So, that is the issue. I will fix it asap.
El mié., 4 sept. 2019 a las 9:43, Jama Hussein Mohamud (<
[email protected]>) escribió:
… I am using OpenCV version '4.1.0'. Do you think this is the problem? I
will downgrade, and get back to you if the problem still persists.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7?email_source=notifications&email_token=ABJRAG6W2PTGIDD3VQ6F74DQH5RJTA5CNFSM4IQ2HJDKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD52VPZI#issuecomment-527783909>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABJRAG4CMCLSMP2IUJP4BYTQH5RJTANCNFSM4IQ2HJDA>
.
|
Nice, I was about to try. But good to hear that you figure out the problem. |
Very interesting, it working now. i will check the annotation results if it is as expected. But so far no problem. but we should put some-kind exception or version check in the code. so that when there is a particular version it gives the expected results from contours. Thanks. |
It is fixed now for version 4 of OpenCV. |
Hi @joheras Results are very interesting. Even updating to the latest version by referencing to this issue #8. The bounding boxes are mislocated and sometimes my ground-through annotations are totally gone after augmenting. for example, look at the below images. Image one is the ground-through image and the second one is the augmented image. i can say it is a huge difference. could you please confirm the output results of the images I have shared with you earlier. maybe we can reproduce the bug. NB: this image is part of the ignored classes. And it consists of one type class (e.g. class 3). In ignoring some classes, I was expecting nothing to happen to such classes. |
Hi,
I really thank you for this amazing work/research/tool. it eases a lot of work that would have consumed a lot of time for everyone.
I wanted to try augmenting an instance segmentation data that was annotated via coco format. but I want to augment only a couple of classes, instead of augmenting all classes. Is such an option available in your tool.
Thanks.
The text was updated successfully, but these errors were encountered: