Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
pipe = pipeline("text-classification")
|
| 5 |
+
|
| 6 |
+
def clf(text):
|
| 7 |
+
result = pipe(text)
|
| 8 |
+
label = result[0]['label']
|
| 9 |
+
score = result[0]['score']
|
| 10 |
+
res = {label:score,'POSITIVE' if label=='NEGATIVE' else 'NEGATIVE': 1-score}
|
| 11 |
+
return res
|
| 12 |
+
|
| 13 |
+
demo = gr.Interface(fn=clf, inputs="text", outputs="label")
|
| 14 |
+
gr.close_all()
|
| 15 |
+
demo.launch(share=True)
|