Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,18 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
|
|
|
| 4 |
pipe = pipeline('sentiment-analysis')
|
| 5 |
-
text = gr.TextArea('enter some text!')
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load the sentiment analysis model
|
| 5 |
pipe = pipeline('sentiment-analysis')
|
|
|
|
| 6 |
|
| 7 |
+
# Function to pass user input to the pipeline
|
| 8 |
+
def analyze_sentiment(input_text):
|
| 9 |
+
return pipe(input_text)
|
| 10 |
+
|
| 11 |
+
# Create the Gradio interface
|
| 12 |
+
demo = gr.Interface(
|
| 13 |
+
fn=analyze_sentiment,
|
| 14 |
+
inputs=gr.TextArea(label="Enter some text!"),
|
| 15 |
+
outputs=gr.JSON(label="Sentiment Result")
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
demo.launch()
|