Spaces:
Sleeping
Sleeping
Commit
·
7083a37
1
Parent(s):
528a96f
first implementation
Browse files
app.py
CHANGED
|
@@ -1,7 +1,17 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
model_name = "ProsusAI/finbert"
|
| 5 |
+
task = 'sentiment-analysis'
|
| 6 |
|
| 7 |
+
def predict_sentiment(text: str, task: str, model: str):
|
| 8 |
+
"""
|
| 9 |
+
Инициализируйте пайплайн и предскажите им текст
|
| 10 |
+
"""
|
| 11 |
+
pipe = pipeline(task=task, model=model)
|
| 12 |
+
|
| 13 |
+
pipeline_result = pipe(text)
|
| 14 |
+
return pipeline_result
|
| 15 |
+
|
| 16 |
+
demo = gr.Interface(fn=predict_sentiment, inputs="text", outputs="text")
|
| 17 |
demo.launch()
|