Spaces:
Sleeping
Sleeping
File size: 1,228 Bytes
7b1e257 bf265e0 43fcf3d 7b1e257 bf265e0 7b1e257 bf265e0 7b1e257 bf265e0 7b1e257 bf265e0 7b1e257 bf265e0 43fcf3d bf265e0 43fcf3d bf265e0 7b1e257 bf265e0 |
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 28 29 30 31 32 33 34 35 |
import streamlit as st
from transformers import pipeline, AutoConfig
# Model Name (Replace with actual model)
MODEL_NAME = "blaikhole/distilbert-review-bug-classifier"
# Load model config to get label mapping
config = AutoConfig.from_pretrained(MODEL_NAME)
id2label = config.id2label # Example: {0: "Bug", 1: "Feature Request", 2: "Documentation"}
# Create a pipeline for text classification
pipe = pipeline("text-classification", model=MODEL_NAME)
# Streamlit app UI
st.title("Review Bug Classification Demo 🐞")
st.write("Enter some text and the model will predict the bug category.")
# User Input
user_input = st.text_area("Input Text:", height=150)
# Prediction
if st.button("Classify"):
if user_input:
result = pipe(user_input, return_all_scores=True)[0] # Get all scores
# Convert "LABEL_n" to actual class names
predictions = {id2label[int(res['label'].replace('LABEL_', ''))]: res['score'] for res in result}
top_label = max(predictions, key=predictions.get)
# Show decoded label
st.write(f"### 🏆 Predicted Category: `{top_label}`})")
st.json(predictions) # Show confidence scores
else:
st.warning("⚠️ Please enter some text.")
|