Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,9 @@
|
|
| 1 |
-
from flask import Flask, request, render_template
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
| 10 |
-
def home():
|
| 11 |
-
return render_template('index.html')
|
| 12 |
-
|
| 13 |
-
@app.route('/analyze', methods=['POST'])
|
| 14 |
-
def analyze():
|
| 15 |
-
text = request.form['text']
|
| 16 |
-
result = sentiment_analysis(text)
|
| 17 |
-
return render_template('result.html', text=text, result=result)
|
| 18 |
-
|
| 19 |
-
if __name__ == '__main__':
|
| 20 |
-
app.run(debug=True)
|
|
|
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
|
| 3 |
+
# Create a text classification pipeline
|
| 4 |
+
classifier = pipeline("sentiment-analysis")
|
| 5 |
|
| 6 |
+
# Use the pipeline to classify some text
|
| 7 |
+
result = classifier("I love using Hugging Face Transformers!")
|
| 8 |
|
| 9 |
+
print(result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|