kedimestan commited on
Commit
d10f97a
1 Parent(s): f5aabd5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the model and tokenizer
5
+ classifier = pipeline("text-classification",model="AbraMuhara/Fine-TunedBERTURKOfansifTespit")
6
+
7
+ # Define the prediction function
8
+ def classify_text(text):
9
+ # Use the pipeline to classify the text
10
+ result = classifier(text)
11
+ # Extract the label and score
12
+ label = result[0]['label']
13
+ score = result[0]['score']
14
+ return f"Label: {label}\nScore: {score:.4f}"
15
+
16
+ # Create the Gradio interface
17
+ iface = gr.Interface(
18
+ fn=classify_text, # The function to call for predictions
19
+ inputs=gr.Textbox(), # Text input box
20
+ outputs=gr.Text(), # Text output box
21
+ title="Text Classification", # Title of the app
22
+ description="Enter text to classify it and get the prediction label and score." # Description
23
+ )
24
+
25
+ # Launch the interface
26
+ iface.launch()