tirendazakademi commited on
Commit
384c8d4
1 Parent(s): 9d664a8

First model version

Browse files
Files changed (2) hide show
  1. app.py +23 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ classifier = pipeline("sentiment-analysis", model="Tirendaz/my_distilbert_model")
5
+
6
+ def text_classification(text):
7
+ result= classifier(text)
8
+ sentiment_label = result[0]['label']
9
+ sentiment_score = result[0]['score']
10
+ formatted_output = f"This sentiment is {sentiment_label} with the probability {sentiment_score*100:.2f}%"
11
+ return formatted_output
12
+
13
+ examples=["This is wonderful movie!", "The movie was really bad; I didn't like it."]
14
+
15
+ io = gr.Interface(fn=text_classification,
16
+ inputs= gr.Textbox(lines=2, label="Text", placeholder="Enter title here..."),
17
+ outputs=gr.Textbox(lines=2, label="Text Classification Result"),
18
+ title="Text Classification",
19
+ description="Enter a text and see the text classification result!",
20
+ examples=examples)
21
+
22
+ io.launch(inline=False, share=True)
23
+
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ transformers
2
+ gradio