sehaj13 commited on
Commit
3e4d47e
·
verified ·
1 Parent(s): 364b493

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+
3
+ from transformers import pipeline
4
+ import gradio as gr
5
+
6
+ # Load the text classification pipeline with the custom model
7
+ pipe = pipeline("text-classification", model="palakagl/bert_TextClassification")
8
+
9
+ # Define function to classify input text
10
+ def classify_text(text):
11
+ result = pipe(text)
12
+ # Format nicely for display
13
+ return {res["label"]: round(res["score"], 4) for res in result}
14
+
15
+ # Create the Gradio interface
16
+ interface = gr.Interface(
17
+ fn=classify_text,
18
+ inputs=gr.Textbox(lines=3, placeholder="Enter text to classify..."),
19
+ outputs=gr.Label(num_top_classes=3),
20
+ title="BERT Text Classifier",
21
+ description="Enter text to classify using the BERT model from palakagl/bert_TextClassification."
22
+ )
23
+
24
+ # Launch the app
25
+ if __name__ == "__main__":
26
+ interface.launch()