Spaces:
Runtime error
Runtime error
Matheus Frata
commited on
Commit
•
257a521
1
Parent(s):
7931bb8
Add transformers lib
Browse files- app.py +16 -4
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,7 +1,19 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
def greet(name):
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
|
|
|
|
4 |
|
5 |
+
classifier = pipeline("sentiment-analysis")
|
6 |
+
|
7 |
+
|
8 |
+
def check_sentiment(phrase: str) -> str:
|
9 |
+
classification = classifier(phrase)
|
10 |
+
return classification[0]["label"]
|
11 |
+
|
12 |
+
|
13 |
+
def main():
|
14 |
+
iface = gr.Interface(fn=check_sentiment, inputs="text", outputs="text")
|
15 |
+
iface.launch()
|
16 |
+
|
17 |
+
|
18 |
+
if __name__ == "__main__":
|
19 |
+
main()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
transformers==4.19.2
|