Autolabel script, Research notebook, COCO annotations for raw samples #27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is to hand off the work I did this semester in an organized way that will enable the group to continue building off of it if they choose to.
The changes include:
autolabel.py- this is the auto-labelling script I wrote and used to generate labels for the Detectron2 research. I cleaned up and refactored the code, and added a help menu (usepython3 autolabel.py --helpfor usage information). It uses blob detection features of skimage (with parameters set by the user) to automatically generate annotations for quantum dots in the COCO format. It can operate on single image files, or recursively operate on directories of images. You can use the--showflag to preview the labels for an image and tweak the parameters before deciding and saving the labels with the--saveflag. There are various other options and parameters as well, which I will go over in more detail in a hand-off meeting with Harry, which we can record for future students to reference.input_dir/- this is a directory which contains all the images fromraw_samples/, each with a corresponding JSON annotations file in COCO format (e.g.input_dir/32/5a.tif,input_dir/32/5a.jsonetc.). You can update/overwrite these annotations by running theautolabel.pyscript with the--saveflag with your updated parameters for any image/directory of your choosing.Detectron2Research.ipynb- this is my research notebook in which I used Detectron2 with the object detection base modelfaster_rcnn_R_50_C4_1xand trained it on the annotated images of quantum dots. To use it in its current form, you'll need to upload the notebook to Google Colab, then upload your annotated images (input_dir/) to Google Drive, as well as some test images to Google Drive as well. I used132/2b.tifand107/2a.tifbecause they have a known QD count done by humans manually. Make sure to update the filepaths in the notebook (i.e./content/gdrive/train/,/content-gdrive/testetc) to match wherever you upload the files in your Google Drive.generate_labels.sh- this is a bash script which contains all the commands I used to generate labels, all strung together to run concurrently, so you can see what parameters I used, as well as modify parameters and regenerate all the labels if you want.