Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Gradio component with Flash, built using Lightning AI ⚡

License

Notifications You must be signed in to change notification settings

Lightning-Universe/Flash-Gradio_component

Repository files navigation

A Lightning component to serve a Flash Task using Gradio


Install

Use these instructions to install:

git clone https://github.com/Lightning-AI/LAI-flash-gradio-Component.git
cd LAI-flash-gradio-Component
pip install -r requirements.txt
pip install -e .

Use the component

Note: This component currently only supports text_classification task. So make sure to pass:

run_dict = {
    "task": "text_classification",
    "checkpoint_path": "<path to your checkpoint file>",
}

Copy the following code to a file app.py, and run the app using: lightning run app app.py locally. If you want to run the app on cloud, do: lightning run app app.py --cloud.

import lightning as L

from flash_gradio import FlashGradio


class FlashGradioComponent(L.LightningFlow):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.flash_gradio = FlashGradio()

    def run(self):
        # Note: FlashGradio only supports "text_classification" task

        # Pass your `checkpoint_path` - can be a path on your local filesystem or hosted somewhere
        run_dict = {
            "task": "text_classification",
            "checkpoint_path": "https://flash-weights.s3.amazonaws.com/0.7.0/text_classification_model.pt",
        }

        self.flash_gradio.run(
            task=run_dict["task"],
            checkpoint_path=run_dict["checkpoint_path"],
        )

    def configure_layout(self):
        layout = [
            {
                "name": "Predictions Explorer (Gradio)",
                "content": self.flash_gradio,
            },
        ]
        return layout


# To launch the gradio component
app = L.LightningApp(FlashGradioComponent(), debug=True)

About

Gradio component with Flash, built using Lightning AI ⚡

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published