Spaces:
Runtime error
Runtime error
File size: 1,289 Bytes
11dc9a8 adec7fa 7485bd9 7f33b70 adec7fa 378829d 668e514 49176cd e5d85e7 11dc9a8 e5d85e7 378829d adec7fa 11dc9a8 6311754 7485bd9 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 |
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")
predictions_df = pd.DataFrame(dataset,columns=['Headlines_seq', 'URL','Headline_str','Predictions'])
predictions_df_url0 = predictions_df['URL'].iloc[1]
predictions_df_url1 = predictions_df['URL'].iloc[2]
predictions_df_url2 = predictions_df['URL'].iloc[3]
def article_selection(sentiment):
if sentiment == "Positive":
return predictions_df_url0, predictions_df_url1, predictions_df_url2 #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!"""
demo = gr.Interface(
fn=article_selection,
inputs = gr.Dropdown(["Positive","Negative","Neutral"], label="What type of news articles would you like recommended?"),
outputs = [gr.Textbox(label="Sentiment of News Articles")],
)
#TODO
#demo = gr.TabbedInterface([url_demo, voice_demo], ["Swedish YouTube Video to English Text", "Swedish Audio to English Text"])
demo.launch() |