wjbmattingly commited on
Commit
2d64f9f
·
verified ·
1 Parent(s): fa78b96

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import spacy
3
+ import gradio as gr
4
+
5
+ # Initialize the classifier
6
+ classifier = pipeline(
7
+ "sentiment-analysis",
8
+ model="wjbmattingly/human-remains-classifier-modernbert-large",
9
+ max_length=4000,
10
+ truncation=True
11
+ )
12
+
13
+ # Define the prediction function
14
+ def predict_text(text):
15
+ result = classifier(text)
16
+ return result[0]['label'], result[0]['score']
17
+
18
+ # Create the Gradio interface
19
+ demo = gr.Interface(
20
+ fn=predict_text,
21
+ inputs=gr.Textbox(label="Enter text to analyze"),
22
+ outputs=[
23
+ gr.Label(label="Classification"),
24
+ gr.Number(label="Confidence Score")
25
+ ],
26
+ title="Human Remains Text Classifier",
27
+ description="Enter text to classify whether it contains references to human remains."
28
+ )
29
+
30
+ # Launch the app
31
+ if __name__ == "__main__":
32
+ demo.launch()