Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
pipeline =pipeline("text-classification",model="ProsusAI/finbert",trust_remote_code=True)
|
| 5 |
+
|
| 6 |
+
def predict(input_img):
|
| 7 |
+
predictions = pipeline(input_img , threshold=0.5, #optional parameter defaults to 0
|
| 8 |
+
return_scores = False #optional parameter defaults to False
|
| 9 |
+
)
|
| 10 |
+
return predictions
|
| 11 |
+
|
| 12 |
+
gradio_app = gr.Interface(
|
| 13 |
+
predict,
|
| 14 |
+
inputs=gr.Textbox(label="Write a text") ,
|
| 15 |
+
outputs=gr.Text(),
|
| 16 |
+
title="sentiment analysis",
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
if __name__ == "__main__":
|
| 20 |
+
gradio_app.launch()
|