AliArshad's picture
Create app.py
2788d6a
raw
history blame
No virus
1.21 kB
from transformers import pipeline
import gradio as gr
# Load the model using the pipeline
pipe = pipeline("text-classification", model="AliArshad/Severity_Predictor")
from transformers import pipeline
import gradio as gr
# Load the model using the pipeline
pipe = pipeline("text-classification", model="AliArshad/Severity_Predictor")
# Function to predict severity and return confidence score
def predict_severity(text):
# Get prediction from the pipeline
prediction = pipe(text)
# Interpret the label and get the confidence score
label = prediction[0]['label']
confidence = prediction[0]['score']
severity = "Severe" if label == "LABEL_1" else "Non-Severe"
# Return severity and confidence as separate outputs
return severity, confidence
# Define the Gradio interface with a title, specific placeholder message, and a progress bar for confidence
iface = gr.Interface(
fn=predict_severity,
inputs=gr.Textbox(lines=2, placeholder="Please Enter Bug Report Summary"),
outputs=[
gr.Textbox(label="Prediction"),
gr.Number(label="Confidence", precision=2)
],
title="GPT-2 Based Severity Prediction"
)
# Launch the interface
iface.launch()