Phase-Technologies commited on
Commit
f75b5a2
·
verified ·
1 Parent(s): e6de672

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -7
app.py CHANGED
@@ -1,13 +1,24 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load your model
5
- model = pipeline("fill-mask", model="Phase-Technologies/RoBERTo")
6
 
7
- # Define inference function
8
- def predict(text):
9
- return model(text)
 
 
 
10
 
11
- # Create Gradio UI
12
- iface = gr.Interface(fn=predict, inputs="text", outputs="json")
 
 
 
 
 
 
 
 
13
  iface.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load the text classification model
5
+ model = pipeline("text-classification", model="Phase-Technologies/RoBERTo")
6
 
7
+ # Define the function to classify text
8
+ def classify_text(text):
9
+ result = model(text)
10
+ label = result[0]['label'] # Get predicted label (e.g., "POSITIVE" or "NEGATIVE")
11
+ confidence = round(result[0]['score'] * 100, 2) # Get confidence score
12
+ return f"Prediction: {label} (Confidence: {confidence}%)"
13
 
14
+ # Create Gradio Interface
15
+ iface = gr.Interface(
16
+ fn=classify_text,
17
+ inputs=gr.Textbox(label="Enter Text for Sentiment Analysis"),
18
+ outputs=gr.Textbox(label="Model Prediction"),
19
+ title="RoBERTo Sentiment Classifier",
20
+ description="Enter a sentence, and the model will classify it as **Positive** or **Negative**."
21
+ )
22
+
23
+ # Launch the Gradio app
24
  iface.launch()