Spaces:
Sleeping
Sleeping
Delete app1.py
Browse files
app1.py
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
import torch
|
2 |
-
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
3 |
-
import gradio as gr
|
4 |
-
|
5 |
-
# Path to the saved model in Hugging Face Spaces
|
6 |
-
model_name = 'AliArshad/SeverityPredictor' # Replace with your actual username and model name
|
7 |
-
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
8 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
9 |
-
|
10 |
-
|
11 |
-
# Function for prediction
|
12 |
-
def xl_net_predict(text):
|
13 |
-
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=100)
|
14 |
-
with torch.no_grad():
|
15 |
-
outputs = model(**inputs)
|
16 |
-
logits = outputs.logits
|
17 |
-
probabilities = torch.softmax(logits, dim=1)
|
18 |
-
predicted_class = torch.argmax(probabilities).item()
|
19 |
-
return "Severe" if predicted_class == 1 else "Non-severe"
|
20 |
-
|
21 |
-
# Customizing the interface
|
22 |
-
iface = gr.Interface(
|
23 |
-
fn=xl_net_predict,
|
24 |
-
inputs=gr.Textbox(lines=2, label="Summary", placeholder="Enter text here..."),
|
25 |
-
outputs=gr.Textbox(label="Predicted Severity"),
|
26 |
-
title="XLNet Based Bug Report Severity Prediction",
|
27 |
-
description="Enter text and predict its severity (Severe or Non-severe).",
|
28 |
-
theme="huggingface",
|
29 |
-
examples=[
|
30 |
-
["Can't open multiple bookmarks at once from the bookmarks sidebar using the context menu"],
|
31 |
-
["Minor enhancements to make-source-package.sh"]
|
32 |
-
],
|
33 |
-
allow_flagging=False
|
34 |
-
)
|
35 |
-
|
36 |
-
|
37 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|