This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for loading datasets and visualizing model predictions…
… via FiftyOne (#360) * add fiftyone module availability * add fiftyone datasource * add video classification data source * add fiftyone classification serializer * optimizations, rework fo serializer * support classification, detection, segmentation * values list, load segmentation dataset in load sample * FiftyOneLabels test * serializer and detection tests * fiftyone classification tests * segmentation and video tests * add detections serializiation test * cleanup * fix test * inherit fiftyonedatasource * tweaks * fix class index * adding helper functions for common operations * updating interface * always use a Label class * exposing base class params * indent * revert segmentation optimization * revert to mutli * linting * adding support for label thresholding * linting * update changelog * resolve some issues, clean API * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * normalize detection labels * normalize detection labels * fiftyone serializer return filepaths, paths data sources store filepaths * formatting * formatting * remove fiftyone from dir, rename fiftyone_visualize() * update metadata to contain dictionaries * add fiftyone docs * update fiftyone examples * rename from_fiftyone_datasets to from_fiftyone * fiftyone_visualize to visualize, update docs * resolve comments * resolve test issues * formatting * formatting * yapf formatting * update for current FO version * resolve metadata batch issue * use current FO release, update test requirements * syntax * update test * update tests * yapf formatting * one more test... Co-authored-by: brimoor <[email protected]> Co-authored-by: tchaton <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
01fef90
commit 25d6633
Showing
43 changed files
with
1,901 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
######## | ||
FiftyOne | ||
######## | ||
|
||
We have collaborated with the team at | ||
`Voxel51 <https://voxel51.com>`_ to integrate their tool, | ||
`FiftyOne <https://fiftyone.ai>`_, into Lightning Flash. | ||
|
||
FiftyOne is an open-source tool for building high-quality | ||
datasets and computer vision models. The FiftyOne API and App enable you to | ||
visualize datasets and interpret models faster and more effectively. | ||
|
||
This integration allows you to view predictions generated by your tasks in the | ||
:ref:`FiftyOne App <fiftyone:fiftyone-app>`, as well as easily incorporate | ||
:ref:`FiftyOne Datasets <fiftyone:fiftyone-basics>` into your tasks. All image and video tasks | ||
are supported! | ||
|
||
.. raw:: html | ||
|
||
<div style="margin-top: 20px; margin-bottom: 20px"> | ||
<video controls muted poster="https://pl-flash-data.s3.amazonaws.com/assets/fiftyone/fiftyone_poster.png" style="width: 100%;"> | ||
<source src="https://pl-flash-data.s3.amazonaws.com/assets/fiftyone/fiftyone_long_sizzle.mp4" type="video/mp4"> | ||
</video> | ||
</div> | ||
|
||
************ | ||
Installation | ||
************ | ||
|
||
In order to utilize this integration with FiftyOne, you will need to | ||
:ref:`install the tool<fiftyone:installing-fiftyone>`: | ||
|
||
.. code:: shell | ||
pip install fiftyone | ||
***************************** | ||
Visualizing Flash predictions | ||
***************************** | ||
|
||
This section shows you how to augment your existing Lightning Flash workflows | ||
with a couple of lines of code that let you visualize predictions in FiftyOne. | ||
You can visualize predictions for classification, object detection, and | ||
semantic segmentation tasks. Doing so is as easy as updating your model to use | ||
one of the following serializers: | ||
|
||
* :class:`FiftyOneLabels(return_filepath=True)<flash.core.classification.FiftyOneLabels>` | ||
* :class:`FiftyOneSegmentationLabels(return_filepath=True)<flash.image.segmentation.serialization.FiftyOneSegmentationLabels>` | ||
* :class:`FiftyOneDetectionLabels(return_filepath=True)<flash.image.detection.serialization.FiftyOneDetectionLabels>` | ||
|
||
The :func:`~flash.core.integrations.fiftyone.visualize` function then lets you visualize | ||
your predictions in the | ||
:ref:`FiftyOne App <fiftyone:fiftyone-app>`. This function accepts a list of | ||
dictionaries containing :ref:`FiftyOne Label<fiftyone:using-labels>` objects | ||
and filepaths which is the exact output of the FiftyOne serializers when the flag | ||
``return_filepath=True`` is specified. | ||
|
||
.. literalinclude:: ../../../flash_examples/integrations/fiftyone/image_classification.py | ||
:language: python | ||
:lines: 14- | ||
|
||
|
||
*********************** | ||
Using FiftyOne datasets | ||
*********************** | ||
|
||
The above workflow is great for visualizing model predictions. However, if you | ||
store your data in a FiftyOne Dataset initially, then you can also visualize | ||
ground truth annotations. This allows you to perform more complex analysis with | ||
:ref:`views <fiftyone:using-views>` into your data and | ||
:ref:`evaluation <fiftyone:evaluating-models>` of your model results. | ||
|
||
The | ||
:meth:`~flash.core.data.data_module.DataModule.from_fiftyone` | ||
method allows you to load your FiftyOne Datasets directly into a | ||
:class:`~flash.core.data.data_module.DataModule` to be used for training, | ||
testing, or inference. | ||
|
||
.. literalinclude:: ../../../flash_examples/integrations/fiftyone/image_classification_fiftyone_datasets.py | ||
:language: python | ||
:lines: 14- | ||
|
||
|
||
********************** | ||
Visualizing embeddings | ||
********************** | ||
|
||
FiftyOne provides the methods for | ||
:ref:`dimensionality reduction<fiftyone:brain-embeddings-visualization>` and | ||
:ref:`interactive plotting<fiftyone:embeddings-plots>`. When combined with | ||
:ref:`embedding tasks <image_embedder>` in Flash, you can accomplish | ||
powerful workflows like clustering, similarity search, pre-annotation, and more | ||
in only a few lines of code. | ||
|
||
.. literalinclude:: ../../../flash_examples/integrations/fiftyone/image_embedding.py | ||
:language: python | ||
:lines: 14- | ||
|
||
.. image:: https://pl-flash-data.s3.amazonaws.com/assets/fiftyone/embeddings.png | ||
:alt: embeddings_example | ||
:align: center | ||
|
||
------ | ||
|
||
************* | ||
API reference | ||
************* | ||
|
||
.. _from_fiftyone: | ||
|
||
DataModule.from_fiftyone | ||
------------------------ | ||
|
||
.. automethod:: flash.core.data.data_module.DataModule.from_fiftyone | ||
:noindex: | ||
|
||
.. _fiftyone_labels: | ||
|
||
FiftyOneLabels | ||
-------------- | ||
|
||
.. autoclass:: flash.core.classification.FiftyOneLabels | ||
:members: | ||
|
||
.. _fiftyone_segmentation_labels: | ||
|
||
FiftyOneSegmentationLabels | ||
-------------------------- | ||
|
||
.. autoclass:: flash.image.segmentation.serialization.FiftyOneSegmentationLabels | ||
:members: | ||
|
||
.. _fiftyone_detection_labels: | ||
|
||
FiftyOneDetectionLabels | ||
----------------------- | ||
|
||
.. autoclass:: flash.image.detection.serialization.FiftyOneDetectionLabels | ||
:members: | ||
|
||
|
||
.. _fiftyone_visualize: | ||
|
||
visualize | ||
--------- | ||
|
||
.. autofunction:: flash.core.integrations.fiftyone.visualize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.