DigitalSlideArchive / superpixel-classification

A test cli for classifying superpixels with arbitrary labels
Other
5 stars 1 forks source link

Support BatchBALD in active learning #11

Closed Leengit closed 1 month ago

Leengit commented 7 months ago

We currently support selection of active learning samples via 3 metrics: confidence, margin, and negative_entropy. To this we wish to add a fourth, batchbald.

Leengit commented 7 months ago

Design considerations include that the existing metrics are implemented for a tensorflow model, but the library we are using to implement BatchBALD is based upon torch. The current plan is to change the existing implementation, currently in superpixel_classification/SuperpixelClassification/SuperpixelClassification.py, in several ways.

  1. The existing implementation is in terms of global functions, but the plan is to switch to class methods.
  2. There will be a SuperpixelClassificationBase class that implements functionality that does not depend upon either the tensorflow or torch packages.
  3. There will be two subclasses derived from it, SuperpixelClassificationTensorflow and SuperpixelClassificationTorch, each implementing those methods that depend upon tensorflow or torch respectively.
  4. Each of these three classes will be in its own file, with name equal to the class name and a .py suffix.
  5. We'll add batchbald to the user interface alongside confidence, margin, and negative_entropy.
  6. The original SuperpixelClassification.py will use its if __name__ == '__main__': section to check args.certainty, import either SuperpixelClassificationTensorflow or SuperpixelClassificationTorch (and, from within them, import tensorflow or torch, respectively), and instantiate and invoke the class.
  7. The installation of superpixel-classification (e.g., in our docker image) will not have tensorflow as a requirement any more. Instead, both tensorflow and torch will be options, as in pip install superpixel-classification[tensorflow,torch].
Leengit commented 7 months ago

Please see Pull Request #12 for any subsequent discussions.

Leengit commented 6 months ago

Pull request #12 implements the needed re-architecturing. It also includes a start at the torch-specific code, but it is not yet debugged and is not made accessible to the user by that pull request. Making debugged torch-specific code available to the user will be done in a subsequent pull request.

manthey commented 1 month ago

This was done in #16.