-
Notifications
You must be signed in to change notification settings - Fork 11.7k
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
Preparing data for training #297
Comments
@Aptamer1 I am at the same point. I just done with the simple shapes demo. Now, I would like to jump to start training with own images and manually prepared masks. Maybe, we can exchange info through the learning process. Can you share your machine specs? Are you using windows? Do you have enough gpu memory? When I was doing object detection, I used https://github.com/tzutalin/labelImg to annotate the bounding boxes. For annotating mask, the author of this repo mentioned http://labelme.csail.mit.edu/ and http://labelml.com/ I am checking that right now, and see what does the software outputs. Probably, a json file with info about bboxes and masks. http://cocodataset.org/#download , section 4.1 highlights the coco annotation format. CocoApi includes pycocoDemo where you can see each element of the annotation. |
@fastlater thanks for the info, I was using the labellmg for the bounding boxes too. For the masks I will look at the tools you sent and see how far I can get. |
@Aptamer1 I am using windows + anaconda too. Also, I am not very familiar with python either (I am more familiar with C#) so that is one of the reasons I go very slow reading and understanding the scripts. |
@fastlater I think for instance segmentation every mask will be a seperate image. Like the current kaggle data science bowl. Every mask is a binary form of the object you want to detect and each masked object has its own image. Here the masks can also be defined as RLE format, but that is not required for this algorithm. *Just finished the annotations. I now have 2 folders, one folder with the masks for each individual object and one with the annotations. The annotations are in xml files, but since I did polygons and masks it seems there are 2 annotations in the file:
Entire lists per image. I guess I can take the polygon data, it seems this can be converted using pycocotools to coco format - have not checked how yet though: #204 This thread #155 mentions that 1 json file is required for all images, apparently there is a conversion code somewhere. After using the labelme tool we get annotation seperately for each image Not really sure how it looks in the cocodataset. Will look into the issues and algorithm once I can find some more time :) |
@Aptamer1 About the coco format, I did my research and inspected the One json file includes all the info about dataset, images details, annotations etc as illustrated in the image below: For example (in inspect_data), when The json file should looks like
If more images, more elements will be included in the lists of images and annotations. I want to test it with at least 2 or 3 images with 2 or 3 clear instances per images. As you can see from code above, your list of points |
@fastlater Thanks for the great info, I will look into this to see if I can find a way to convert the polygons to the json format. I will have a look at it later today and see what the output is, after I install pycocotools Or we need to look for a script that converts PASCALVOC (output from labelme?) to MS COCO, it's easy to find a mscoco to pascal but not other way around |
@Aptamer1 When you done the test, let me know what does the script outputs. |
@Aptamer1 I want to share this repo: https://github.com/killthekitten/kaggle-ds-bowl-2018-baseline |
@fastlater That repo looks interesting, might be worth checking out as an easier alternative. Still trying to install pycocotools, have not had a lot of time to get it installed, probalby will find some time later this week. pycocotools keeps giving an error that it cannot find the pyococotools._mask, there are some issues that are relating to the same problem, but they do not seem to help for me. Will try again later this week on my pc at home. For now I will look into the algorithm from kaggle which you sent |
Hi guys, I just stumbled upon your discussion. I am also a newbie and wanted to try to apply the Mask R-CNN algorithm to the Kaggle DS Bowl 2018 data. I wanted to ask if anyone of you has already succeeded with this? Maybe we could help each other via skype/TV and exchange experiences? Thanks! |
@r0nh there is a baseline demo using this repo in that kaggle challenge forum. |
Do you mean this one: https://github.com/killthekitten/kaggle-ds-bowl-2018-baseline Did you manage to run it on your own dataset? |
@r0nh It does work fine. |
@fastlater got my pc back up and running and can spend some time again on this project. I just got pycocotools working and am looking into this algorithm. this line is giving me an error; id_extractor = re.compile(f"{base_path}{os.sep}(?P<image_id>.){os.sep}masks{os.sep}(?P<mask_id>.).png") |
@Aptamer1 About the error, I don't remember to have issues in that line but since you are using windows, you remember that I had to add these 2 lines in I recommend you to "abuse" of print() function. Place print in many different locations so you will go understanding more and more over time. |
@fastlater thanks for the tip, I will try out some things later after work |
We are in the same boat. I guess it will be possible but the script was prepared to work for 1 class only so there will be job to do I guess. I opened an issue there about how to do multi-class segmentation with their script but they told me to check the shapes demo. Let me know if you solve the problem using the tip. |
According to the shapes notebook example you have to mention as many masks (0 for background, 1 for the instance) as instances you have, no matter the class of the object. |
Hello guys @Aptamer1 @fastlater I trained my own images using Now I want to do semantic segmentation and instance segmentation. |
@Abduoit That annotation tool can be used, I was using the mit labelme annotation but either is ok I guess About the steps, I'm still figuring them out myself. I'm now trying out the killthekitty algorithm, here you need the masks and your original images and the algorithm will make the bounding boxes. I have not had time yet to try this on my own dataset, figuring out where to put my input files so I can try and run the algorithm, since I'm not a programmer it takes quite some time for me to figure this out, however fastlater did say he got it working. Please join the discussion and if you figure something out let us know :) |
@Aptamer1 @Abduoit Matterport's blog should tell you what sort of JSON file you can directly use, starting from the balloon example : https://engineering.matterport.com/splash-of-color-instance-segmentation-with-mask-r-cnn-and-tensorflow-7c761e238b46 |
@Paulito-7 Thank you for your comment. Any feedback is appreciated. I succesfully tested mask rcnn for 1 class segmentation using my own dataset (using killthekitty code) . Now, I would like to try the multi-class segmentation and I am also trying to figure out how to make the mask correspond to the right class. I dont know if I need to paint them of a different colour or just notify the script that x mask belong to y class. I will be working on it since today. Lets keep in touch and please share with us if you figure it out before me. @Abduoit As mentioned in the blog of the project (link shared in the previous comment), there isn’t a universally accepted format to store segmentation masks. This repo uses a single json file to load the segmentation data as polygon points (+image info + bounding box + etc). killthekitty algorithm save them as PNG images (each sample has a folder named images and a folder named masks). I will keep trying with the killthekitty code for multi-class task but if I get too many problems, I will go back to the original script and input the masks as polygon points since the original script is already working for multiclass instance segmentation. |
I wrote a blog post about this repo, and I made a point to cover how to build your own dataset. The code from the blog post is in the samples/balloons folder. Hope it helps answer some of the questions in this thread. |
@waleedka : This is very useful. Could you tell me the reason why I make a bounding box from the mask with different 6 pixels give lower performance than 1 pixel?
|
@John1231983 I dont think this is the thread to post that question. We are discussing about how to prepare the data. Can you please ask your question in a different issue? |
@fastlater |
@Paulito-7 Thank you for your feedback. I was working in another issue yesterday so I ran out of time. Keep in touch and lets see if we can find the best solution to this. |
@fastlater |
@Paulito-7 I have been inspecting the code, especially the load_mask function and I think the only variable to change is class_ids. |
I am also trying to train my own dataset. Because the memory of GPU is not big enough, I clipped images (1920x1080 pixel) into 256x256 pixel as training dataset to train the model, but when I use the model to detect images (1920x1080 pixel), the test result show "No instances to display error"! Is it because I clipped images into 256x256 to train the model? |
Hi @waleedka @Aptamer1 Do you guys know how to run it using my own file I keep getting this error.
Thanks |
I just finished training my own dataset for one class and it worked using the balloon example. |
@Aptamer1 How did you adjust demo jupyter notebook code, I tried to replace file
|
@Abduoit what I did was copy the balloon.py file and did a replace (text) balloon with the object I wanted to find. After this I trained the file and did the same in the demo file. The algorithm will ask for coco in default, you can adjust it to your own file (just only replace the last part of the file name like this: mask_rcnn_coco.h5 ==> mask_rcnn_balloon.h5) I just left it at coco :) I think the demo file will also by default go to images directory, here you can put the images you want to use your detection algorithm on. If this is unclear I can send you my demo file |
@Aptamer1 I even tried to replace |
Hey guys I stumbled across this forum and am also trying to train my own dataset. I already have a few images and their respective segmentation masks. I noticed that the mask has to be in the format [height, width, # of instances] but when I load my mask image (which is already black and white) it always comes back in the rgb space and I can't update the 3rd channel to be the number of instances. Does anyone else have this issue? |
@Abduoit Did you find a solution to your problem? Make sure your InferenceConfig matches the Config you used to train. Check to see if they have the same number of classes. |
@Chasesc In coco.py there is
For me when I trained it with only one class I have like this
Is this correct ? is this what do you mean ? |
Ensure your InferenceConfig also only has two classes. (Like your training config) For example,
I believe the problem is that your inference config had the incorrect number of classes. |
Hi... I am also facing a similar problem. I am trying to use the Mask R-CNN for a different database. When I try running the model, I get the following error: ValueError: Dimension 1 in both shapes must be equal, but are 264 and 324. Shapes are [1024,264] and [1024,324]. for 'Assign_376' (op: 'Assign') with input shapes: [1024,264], [1024,324]. I get this error when I run the network with a Resnet50 backend. While running the network with a Resnet101 backend, the error is similar but the 'Assign_376' gets changed to 'Assigned_682'. Can someone please suggest what could be the reason. Thanks in advance. |
@Venky-Iyer Did what I suggested not work? |
Hi @Chasesc It is loading the weights now... I had not excluded certain layers while loading the weights. Thanks for your help. |
Hello, I'm trying to train on my own dataset. I have prepared and annotated my data with VIA Image annotating tool. but while verifying my data with my own inspect_data.ipynb file I am getting error as AttributeError: 'list' object has no attribute 'values' from 2 days I am trying to resolve this error but had no success. `AttributeError Traceback (most recent call last) ~\Desktop\Mask_RCNN\samples\window\window.py in load_window(self, dataset_dir, subset) AttributeError: 'list' object has no attribute 'values'` Please Help Me Out! |
@siddheshgujal |
@siddheshgunjal could you fix the problem? |
I had to use VIA 1.0 because editing the json file is bigger pain than that. |
Hi,
This is a really great project with great possiblities.
I myself am a medical phd student, consequently my programming knowledge is limited.
I have my own dataset of images with cells, which I want to try and train this model with.
I have used the object detection of google tensorflow before and this worked.
However I have not made a model with masks before, neither can I get pycocotools to work.
I did get the training shapes to work.
I was wondering if someone could explain to me the tools they use on how to make their own dataset fit for this model?
I presume the detection works the same as the tensorflow object detection API, but how do you prepare your mask data? What tools do you use and how should it be prepared for the input?
Any help is greatly appreciated,
Kind regards,
Sören
The text was updated successfully, but these errors were encountered: