yukta1 commited on
Commit
1934621
·
verified ·
1 Parent(s): d55d183

Delete app.py

Browse files

from transformers import pipeline
import gradio as gr

# Load the sentiment analysis pipeline
classifier = pipeline("sentiment-analysis")

# Define the prediction function
def analyze_sentiment(text):
result = classifier(text)[0]
label = result['label']
score = round(result['score'], 3)
return f"Sentiment: {label} (Confidence: {score})"

# Create the Gradio interface
interface = gr.Interface(
fn=analyze_sentiment,
inputs=gr.Textbox(lines=4, placeholder="Enter some text here..."),
outputs="text",
title="Sentiment Analysis with Hugging Face 🤗",
description="Enter text to find out if the sentiment is positive, negative, or neutral."
)

# Run the app
if __name__ == "__main__":
interface.launch()

Files changed (1) hide show
  1. app.py +0 -7
app.py DELETED
@@ -1,7 +0,0 @@
1
- import gradio as gr
2
-
3
- def greet(name):
4
- return f"Hello, {name}!"
5
-
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()