Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
# Load the model using the pipeline
|
| 5 |
+
pipe = pipeline("text-classification", model="AliArshad/Severity_Predictor")
|
| 6 |
+
from transformers import pipeline
|
| 7 |
+
import gradio as gr
|
| 8 |
+
|
| 9 |
+
# Load the model using the pipeline
|
| 10 |
+
pipe = pipeline("text-classification", model="AliArshad/Severity_Predictor")
|
| 11 |
+
|
| 12 |
+
# Function to predict severity and return confidence score
|
| 13 |
+
def predict_severity(text):
|
| 14 |
+
# Get prediction from the pipeline
|
| 15 |
+
prediction = pipe(text)
|
| 16 |
+
|
| 17 |
+
# Interpret the label and get the confidence score
|
| 18 |
+
label = prediction[0]['label']
|
| 19 |
+
confidence = prediction[0]['score']
|
| 20 |
+
severity = "Severe" if label == "LABEL_1" else "Non-Severe"
|
| 21 |
+
|
| 22 |
+
# Return severity and confidence as separate outputs
|
| 23 |
+
return severity, confidence
|
| 24 |
+
|
| 25 |
+
# Define the Gradio interface with a title, specific placeholder message, and a progress bar for confidence
|
| 26 |
+
iface = gr.Interface(
|
| 27 |
+
fn=predict_severity,
|
| 28 |
+
inputs=gr.Textbox(lines=2, placeholder="Please Enter Bug Report Summary"),
|
| 29 |
+
outputs=[
|
| 30 |
+
gr.Textbox(label="Prediction"),
|
| 31 |
+
gr.Number(label="Confidence", precision=2)
|
| 32 |
+
],
|
| 33 |
+
title="GPT-2 Based Severity Prediction"
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
# Launch the interface
|
| 37 |
+
iface.launch()
|