Spaces:
Runtime error
Runtime error
File size: 2,372 Bytes
11dc9a8 adec7fa 7485bd9 7f33b70 adec7fa a3d5133 f7c6bf3 11dc9a8 fe08354 378829d adec7fa 92533eb b4aeeaf 92533eb b4aeeaf 3c22553 adec7fa b4aeeaf 92533eb 11dc9a8 92533eb 6311754 5673b9a b4aeeaf 11dc9a8 92533eb 0551e7e b4aeeaf 92533eb 11dc9a8 ce4abb2 11dc9a8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
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!"""
def thanks():
return f"""Thank you for making our model better!"""
description1 = '''
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.
'''
description2 = '''
This application recommends news articles depending on the sentiment of the headline.
Enter a news article url and its sentiment to help us improve our model.
The more data we have, the better news articles we can recommend to you!
'''
suggestion_demo = gr.Interface(
fn=article_selection,
title = 'Recommending News Articles',
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 = description1
)
manual_label_demo = gr.Interface(
fn=thanks,
title="Manually Label a News Article",
inputs=[gr.Textbox(label = "Paste in URL of news article here."),
gr.Dropdown(["Positive","Negative","Neutral"], label="Select the sentiment of the news article.")],
outputs = gr.Textbox(),
description = description1
)
demo = gr.TabbedInterface([suggestion_demo, manual_label_demo], ["Get recommended news articles", "Help improve our model"])
demo.launch() |