/lai-research-template-with-telegram-component

A copy of the LAI-research template for Unsplash image search demo with additional component to notify about the deployment stages and usage

Primary LanguagePython

⚡️ Lightning Research Poster Template 🔬. A fork with messaging

Use this app to share your research paper results. This app lets you connect a blogpost, arxiv paper, and a jupyter notebook and even have an interactive demo for people to play with the model. This app also allows industry practitioners to reproduce your work.

Extending the app with a component

Here the original app has been extended using the Telegram messaging component

The code has been changed in such a way so as to notify the running status of the demo application via telegram messages. If the messages stop or don't get received on a telegram bot channel when the app is deployed and running, it means there is some issue. This notification acts as a heartbeat service for the admin who deploys the app.

Sample Output:

telegram_notifications.png

A better message can be written instead if needed. This is just for the sake of a demo.

Steps to run are as given below in the "Use GitHub template" section of this readme but the command to run with the telegram notification add two environment variables

lightning run app app.py --cloud --env API_TOKEN=<YOUR-TELEGRAM-API-TOKEN> --env CHAT_ID=<YOUR-CHAT-ID>

The app has is currently stopped because the non-stop messages can be overwhelming but helpful to monitor the service is up or not.

Getting started

To create a Research Poster you can install this app via the Lightning CLI or use the template from GitHub and manually install the app as mentioned below.

Installation

With Lightning CLI

lightning install app lightning/research_poster

Use GitHub template

Click on the "Use this template" button at the top, name your app repo, and GitHub will create a fork of this app to your account.

use-template.png

You can clone the forked app repo and follow the steps below to install the app.

git clone https://github.com/YOUR-USERNAME/lightning-template-research-app.git
cd lightning-template-research-app
pip install -r requirements.txt
pip install -e .

Once you have installed the app, you can goto the lightning-template-research-app folder and run lightning run app app.py --cloud from terminal. This will launch the template app in your default browser with tabs containing research paper, blog, Training logs, and Model Demo.

You should see something like this in your browser:

image

You can modify the content of this app and customize it to your research. At the root of this template, you will find app.py that contains the ResearchApp class. This class provides arguments like a link to a paper, a blog, and whether to launch a Gradio demo. You can read more about what each of the arguments does in the docstrings.

Highlights

  • Provide the link for paper, blog, or training logger like WandB as an argument, and ResearchApp will create a tab for each.
  • Make a poster for your research by editing the markdown file in the resources folder.
  • Add interactive model demo with Gradio app, update the gradio component present in the [research_app ( ./research_app/components/model_demo.py) folder.
  • View a Jupyter Notebook or launch a fully-fledged notebook instance (Sharing a Jupyter Notebook instance can expose the cloud instance to security vulnerability.)
  • Reorder the tab layout using the tab_order argument.

Example

# update app.py at the root of the repo
import lightning as L

paper = "https://arxiv.org/pdf/2103.00020.pdf"
blog = "https://openai.com/blog/clip/"
github = "https://github.com/mlfoundations/open_clip"
wandb = "https://wandb.ai/aniketmaurya/herbarium-2022/runs/2dvwrme5"
tabs = ["Poster", "Blog", "Paper", "Notebook", "Training Logs", "Model Demo"]

app = L.LightningApp(
    ResearchApp(
        poster_dir="resources",
        paper=paper,
        blog=blog,
        training_log_url=wandb,
        github=github,
        notebook_path="resources/Interacting_with_CLIP.ipynb",
        launch_jupyter_lab=False,
        launch_gradio=True,
        tab_order=tabs,
    )
)

FAQs

  1. How to pull from the latest template code? Answer