twitter-xlm-roberta-base-se.../app.py

37 lines
1019 B
Python
Raw Normal View History

2023-04-21 06:53:05 +00:00
import gradio as gr
from transformers import pipeline
from gradio.themes.utils import sizes
theme = gr.themes.Default(radius_size=sizes.radius_none).set(
block_label_text_color = '#4D63FF',
block_title_text_color = '#4D63FF',
button_primary_text_color = '#4D63FF',
button_primary_background_fill='#FFFFFF',
button_primary_border_color='#4D63FF',
button_primary_background_fill_hover='#EDEFFF',
)
model_path = "cardiffnlp/twitter-xlm-roberta-base-sentiment"
sentiment_task = pipeline("sentiment-analysis", model=model_path, tokenizer=model_path)
def sentiment_analysis(text):
results = sentiment_task(text)
return results
demo = gr.Interface(fn=sentiment_analysis,
inputs='text',
outputs='text',
2023-04-26 08:42:57 +00:00
css = "footer {visibility: hidden}",
allow_flagging = "never",
2023-04-21 06:53:05 +00:00
theme=theme
)
if __name__ == "__main__":
2023-04-21 08:47:22 +00:00
demo.queue(concurrency_count=10)
2023-04-21 09:29:37 +00:00
demo.launch(server_name = "0.0.0.0")
2023-04-21 06:53:05 +00:00