File size: 698 Bytes
7a0593d
 
 
048b92b
 
 
 
 
 
 
9e96a51
048b92b
 
 
 
 
 
 
 
 
 
 
 
 
9e96a51
048b92b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from transformers import pipeline
import gradio as gr

# Label mapping
human_read = {"LABEL_0": "Negative", "LABEL_1": "Positive"}

# Load model
sentimental = pipeline("text-classification", model="Dmyadav2001/Sentimental-Analysis")

# Prediction function
def predictive_model(texts):
    result = sentimental(texts)
    sentiment = human_read[result[0]["label"]]
    score = result[0]["score"]
    return sentiment, score

# Gradio Interface
interface = gr.Interface(
    fn=predictive_model,
    inputs="text",
    outputs=["text", "number"],
    title="Sentiment-Analysis-App",
    description="Give your text, and my model will predict whether it's Positive or Negative."
)

interface.launch()