import gradio as gr import hopsworks from datasets import load_dataset import pandas as pd project = hopsworks.login() fs = project.get_feature_store() dataset_api = project.get_dataset_api() dataset = load_dataset("torileatherman/sentiment_analysis_batch_predictions", split='train') predictions_df = pd.DataFrame(dataset) predictions_df_url0 = predictions_df['Url'].iloc[0] predictions_df_url1 = predictions_df['Url'].iloc[1] predictions_df_url2 = predictions_df['Url'].iloc[2] predictions_df_urls = [[predictions_df_url0], [predictions_df_url1], [predictions_df_url2]] def article_selection(sentiment): if sentiment == "Positive": return predictions_df_urls #f"""The sentence you requested is Positive!""" elif sentiment == "Negative": return f"""The sentence you requested is Negative!""" else: return f"""The sentence you requested is Neutral!""" description = ''' This application recommends news articles depending on the sentiment of the headline. Enter your preference of what type of news articles you would like recommended to you today: Positive, Negative, or Neutral. ''' demo = gr.Interface( fn=article_selection, title = 'Extractive News Summarizer BART', inputs = gr.Dropdown(["Positive","Negative","Neutral"], label="What type of news articles would you like recommended?"), outputs = gr.Textbox(label="Recommended News Articles", lines=3), description = description, examples=predictions_df_urls) #TODO #demo = gr.TabbedInterface([url_demo, voice_demo], ["Swedish YouTube Video to English Text", "Swedish Audio to English Text"]) demo.launch()