GitHub Actions commited on
Commit ·
db49918
1
Parent(s): 25a11f8
Deploy from GitHub: c19a77175311b0b5be08b3bd1c615146046d62c5
Browse files- app.py +13 -4
- sentiment_analysis.py +2 -6
app.py
CHANGED
|
@@ -1,5 +1,14 @@
|
|
| 1 |
-
|
| 2 |
-
from sentiment_analysis import
|
| 3 |
|
| 4 |
-
# Version: 1.1.
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from sentiment_analysis import sentiment_analysis_tool
|
| 3 |
|
| 4 |
+
# Version: 1.1.5 - Fixed deprecated transformers.tools import
|
| 5 |
+
iface = gr.Interface(
|
| 6 |
+
fn=sentiment_analysis_tool.predicto,
|
| 7 |
+
inputs=gr.Textbox(lines=3, label="Enter text to analyze"),
|
| 8 |
+
outputs=gr.Label(label="Sentiment Analysis Results"),
|
| 9 |
+
title="Sentiment Analysis Tool",
|
| 10 |
+
description="Analyzes the sentiment of text using DistilBERT model"
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
if __name__ == "__main__":
|
| 14 |
+
iface.launch()
|
sentiment_analysis.py
CHANGED
|
@@ -1,13 +1,12 @@
|
|
| 1 |
import requests
|
| 2 |
import gradio as gr
|
| 3 |
from transformers import pipeline
|
| 4 |
-
from transformers import Tool
|
| 5 |
|
| 6 |
-
class SentimentAnalysisTool
|
| 7 |
name = "sentiment_analysis"
|
| 8 |
description = "This tool analyses the sentiment of a given text input."
|
| 9 |
|
| 10 |
-
inputs = ["text"]
|
| 11 |
outputs = ["json"]
|
| 12 |
|
| 13 |
model_id_1 = "nlptown/bert-base-multilingual-uncased-sentiment"
|
|
@@ -41,6 +40,3 @@ class SentimentAnalysisTool(Tool):
|
|
| 41 |
|
| 42 |
# Create an instance of the SentimentAnalysisTool class
|
| 43 |
sentiment_analysis_tool = SentimentAnalysisTool()
|
| 44 |
-
|
| 45 |
-
# Create the Gradio interface
|
| 46 |
-
gr.Interface(fn=sentiment_analysis_tool, inputs=sentiment_analysis_tool.inputs, outputs=sentiment_analysis_tool.outputs).launch()
|
|
|
|
| 1 |
import requests
|
| 2 |
import gradio as gr
|
| 3 |
from transformers import pipeline
|
|
|
|
| 4 |
|
| 5 |
+
class SentimentAnalysisTool:
|
| 6 |
name = "sentiment_analysis"
|
| 7 |
description = "This tool analyses the sentiment of a given text input."
|
| 8 |
|
| 9 |
+
inputs = ["text"]
|
| 10 |
outputs = ["json"]
|
| 11 |
|
| 12 |
model_id_1 = "nlptown/bert-base-multilingual-uncased-sentiment"
|
|
|
|
| 40 |
|
| 41 |
# Create an instance of the SentimentAnalysisTool class
|
| 42 |
sentiment_analysis_tool = SentimentAnalysisTool()
|
|
|
|
|
|
|
|
|