Jordan-Pierce / CoralNet-Toolbox

Tools useful for interacting with CoralNet and other CPCe-related downstream tasks
https://coralnet.ucsd.edu/
Other
17 stars 1 forks source link

Feature Request: Ability to Delete and Regenerate Patches CSV in CoralNet Toolbox #8

Closed m-h-williams closed 1 month ago

m-h-williams commented 2 months ago

Hello Jordan,

I have a suggestion for a useful addition to the CoralNet Toolbox. It would be great to have a feature that allows users to delete patches created using the Patch Extractor Tool and subsequently generate a new patches CSV file. This new CSV file could then be used to train a classifier.

The ability to extract patches from an annotation file is incredibly helpful for visualizing the patches associated with specific labels. However, during this process with my source, I noticed some erroneous patches that I wanted to remove to clean up the annotations. While I can manually delete these patches from the folder on my computer, this doesn't update the annotation file or create a new patches file. I find that this hinders the ability to train a classifier with the cleaned data.

Adding this feature could streamline the process and enhance the utility of the toolbox for users like myself who need to refine their data before training classifiers.

Perhaps there is a work around with the current tools that I am not thinking of. What do you think?

Megan

Jordan-Pierce commented 2 months ago

Hi @m-h-williams,

Thanks for the suggestion; I agree that this would be a great addition. The Patch Extraction tool is an EXE, and I don't have access to the underlying code; however, it wouldn't be too difficult to whip something up in that replicates the utility. I also think it's about time to move towards a customizable patch annotation tool instead of solely relying on the former.

Before jumping into the code, in your mind, what features should be migrated / removed from the existing Patch Extraction tool, and also, what other features would you like to see in the new tool? Having a bigger picture of what is necessary / desired will help with scoping out the work. My thoughts are:

What else would you like to see?

CoralNet-Toolbox_Patch_Annotator drawio

m-h-williams commented 2 months ago

Hi @Jordan-Pierce ,

Thanks for considering my suggestion and for your detailed thoughts on the new tool! The features you've outlined sound great and would significantly enhance the usability of the Patch Extraction tool.

As for additional features, here are my thoughts:

Patch Size and Label Customization: The ability to set patch sizes and customize labels with names and color codes (RGB) sounds perfect. The option to export and import label sets as JSON files would also be very useful for consistency across projects.

* I have a couple of questions here: Would the resolution of the image be set by the user, or would that information be gathered from the image data? Also, are you thinking the color code would be selected from a color wheel, or automatically assigned when a new label is created? I think either option would be great for visualizing different annotations. **Patch Annotation Management**: Including the functionality to create, move, and delete patch annotations is essential, as it gives users the flexibility to refine their datasets directly within the tool. * One suggestion here: it would be helpful to have the ability to toggle annotations for specific labels on and off. This feature would allow users to clear the image of annotation boxes once they are done creating image patches for a particular label, making it easier to see the entire image when working on a new label. The excess of boxes overlaid on an image can sometimes overwhelm the view. **Image Panel and Annotations Management**: Having a scrollable image panel and the ability to load multiple images is important for batch processing. The idea of auto-loading existing annotations and autosaving the patches.csv file as a temp file every few seconds is excellent for preventing data loss. **Annotations Table and Filtering**: The idea of having a table showing the annotations made, with the ability to filter and click to navigate to specific images/annotations, could be very beneficial. As for the auto-navigation to the image/annotations upon clicking in the table, it could be particularly useful for quickly reviewing specific patches or labels, especially if there are many images to sift through. Overall, these features additions are very exciting and would significantly streamline the workflow and improve data management. If there's anything specific you'd like me to focus on or clarify further, please let me know!
Jordan-Pierce commented 2 months ago

I'm thinking:

(for posterity)

CoralNet-Toolbox_Patch_Annotator drawio (1)

m-h-williams commented 2 months ago

This sounds fantastic! I'm really excited about these features and the flexibility they will bring to the tool.

It's great to hear that the image resolution will be read from the native image, allowing for zooming without down-sampling. The flexibility to set patch sizes based on specific needs and resolutions, and the option to have patches of different sizes in the same project, will be incredibly useful.

The toggle feature for turning labels on and off, including a master toggle, is a thoughtful addition. It will definitely help in managing annotations more effectively without overwhelming the view. I'm also looking forward to the annotation table for filtering and editing.

The plans for exporting and importing annotations sound comprehensive and will be a big help for managing datasets. I appreciate the consideration for future updates, like exporting subsets of annotations based on the table view.

Thank you for taking these suggestions into account and for the thoughtful planning. I'm excited to see these features come to life! Please feel free to reach out if there's anything I can do to help or support the development process.

Jordan-Pierce commented 2 months ago

@m-h-williams it's up if you wanna give it a go!

just remember to update:

# cmd

conda activate your_env

git fetch
git pull

python install.py

python toolbox.py

Please log any issues you have in this thread!

m-h-williams commented 2 months ago

@Jordan-Pierce Thank you so much for the hard work you've put into the beta version of the new annotation tool—it's really coming together nicely!

I had a few thoughts and suggestions as I’ve been exploring it:

Thanks again for all your efforts—I'm really excited to see these features evolve. Please let me know if there’s anything I can do to support your work!

Jordan-Pierce commented 2 months ago

@m-h-williams instructions! My bad: here they are, will add to repo next round:

CoralNet Toolbox Instructions

Overview

The CoralNet Toolbox is a Python application built using PyQt5 for image annotation and analysis. This guide provides instructions on how to use the application, including key functionalities and hotkeys.

Main Window

The main window consists of several components:

Menu Bar Actions

Tool Bar

Annotation Window

Hotkeys

Label Window

Thumbnail Window

Confidence Window

Additional Tips

Jordan-Pierce commented 2 months ago

CoralNet-Toolbox QT

Jordan-Pierce commented 2 months ago

When clicking on a label in the lower label window, could it highlight the corresponding patch(es) with that label? I think this would make it easier to identify and manage specific patches.

I noticed we can delete a label, but I was wondering if there's a way to delete a single image patch for a label instead of all the patches for that label? I believe you mentioned this feature might be added later, and I think it would be really helpful. The upcoming addition of the ability to move patches will be a great enhancement as well!

It would also be helpful if the outline of a selected image patch were a brighter color. Right now, it matches the box color, making it a bit difficult to see.

The short code in the label window seems to be getting cut off after four characters, which makes it hard to read the full label.

It would be nice to have toggle on/off buttons for each label, along with a master toggle button. This way, we could start with all labels off and then turn them on one at a time to better see which labels need to be changed. Perhaps this was a feature you were thinking of adding later on as well.

When using the "Edit Label" function, it currently changes the label for all image patches with the previous label.

Additionally, after changing a label, hovering over the new label still shows the old label instead of the updated label (as shown in the screenshot below).

When using the "Add Label" button, it would be helpful if we could select where the image patch is placed. Currently, it seems to create the patch in the middle of the image, which might not be the ideal location.

Lastly, the add, edit, and delete label buttons above the label window are overlapping each other, as seen in the screenshot below.

Jordan-Pierce commented 2 months ago

Regarding resolution, can confirm that it needs to update scaling dynamically; these are my settings

image

If I choose anything less than 150 on a larger monitor it displays as intended. Will have a better fix in the future

Jordan-Pierce commented 2 months ago

@m-h-williams another update if you wanna give it a try; not all has been addressed, but added new stuff and fixed others.

m-h-williams commented 2 months ago

@Jordan-Pierce This is already a fantastic improvement! The confidence window is incredibly helpful for quickly viewing what an image patch looks like. The different colors when a patch is highlighted make it much easier to manage annotations, and the ability to move patches around works seamlessly—this really enhances the annotation process.

The overlap of the edit tabs and the cutoff labels was indeed a scaling issue on my computer. I have a 4K screen, but even without adjusting the scaling, the labels are now much easier to read. Thank you for addressing that!

I have a few more suggestions that I think could further enhance the tool:

Thank you again for your hard work on these updates! These improvements have already made a big difference.

Jordan-Pierce commented 2 months ago

Importing Label Sets: Could we add an option to import a label set so that all the label options are pre-loaded in the label window? This would help reduce the chance of typos when adding new annotations, ensuring consistency across different images.

Hotkeys for Scrolling Through Image Patches: The hotkeys for scrolling through labels are great! It would be awesome if we could also use hot keys to scroll through the image patches of a selected label. My thought is that when a label is selected, you could use the confidence window to quickly check each annotation, delete it if it's incorrect, and then automatically move to the next image patch with the same label. Or, if the label is correct, you could use a hot key to move to the next patch. I think this would make cleaning annotations much faster than selecting each image patch one at a time.

Selecting and Deleting Multiple Patches: Could we add a feature that allows users to select multiple patches at once—perhaps by dragging the mouse over them—and then delete or rename the group? For example, in the screenshot below, algae has been incorrectly labeled as pebble. It would be really helpful if we could select these patches in bulk and delete/correct them all at once.

Will let you know when ML is out.

m-h-williams commented 2 months ago

Thanks, @Jordan-Pierce ! The import/export feature for label sets is what I was looking for. The future plans you mentioned, like importing labels from CoralNet and defining a "Project" for saving everything together, sound like great improvements that will streamline the workflow even further.

Very excited to hear that hotkeys for scrolling through image patches and adjusting labels within the confidence window are on the way. And having hotkeys for navigating through thumbnails will definitely speed up the process — great idea!

The upcoming multi-select feature will be a great improvement, especially when dealing with large datasets. I totally understand that it requires some reworking of the existing setup, but I’m really looking forward to it when it’s ready.

One quick question: When creating new labels, how do I ensure I’m generating the correct unique ID for them? I noticed the IDs in the JSON file are quite specific, and I want to make sure I’m doing it correctly.

Thanks again, I'm really excited to see these new features roll out!

Jordan-Pierce commented 2 months ago

One quick question: When creating new labels, how do I ensure I’m generating the correct unique ID for them? I noticed the IDs in the JSON file are quite specific, and I want to make sure I’m doing it correctly.

Jordan-Pierce commented 2 months ago

@m-h-williams machine learning has been added.; might be useful to go over it via a call but briefly:

To use a model; you have three options:

Predictions will show in the confidence window when the annotation is selected (if you move or adjust their size, you'll get a warning, as once you change a prediction, it doesn't really hold true anymore). I recommend switching to left hand on cntrl + arrows, and right hand on mouse. Use cntrl + left / right to cycle through all annotation on an image, and use the mouse to select any of the predicted categories, or any other label in the label window. To switch to the next image, do cntrl + up / down.

Last thing to note is the model: still with the smallest (tiny / t) model, and you can train even on a CPU in a reasonable amount of time, and inference is fast. The models are coming from ultralytics, so please make yourself familiar with their license.

m-h-williams commented 2 months ago

@Jordan-Pierce I used the machine learning option in the annotate tool, and it worked great! I’d love to set up a call to go over it in more detail. I’ll email you to arrange a time.

I have a couple of small suggestions:

I'll definitely familiarize myself with the models from Ultralytics and their license. If there’s anything else I should be aware of or any additional resources you recommend, please let me know.

Thanks again for all the work you’ve put into these updates!