Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -1,17 +1,19 @@
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"),
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ examples=["This is wonderful movie!", "The movie was really bad; I didn't like it."]
5
 
 
 
 
 
 
 
6
 
7
+ model_path = "waelChafei/bertuned"
8
 
9
+
10
+ model = BertForSequenceClassification.from_pretrained(model_path)
11
+ tokenizer= BertTokenizerFast.from_pretrained(model_path)
12
+ nlp= pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
13
+
14
+ def text_classification(text):
15
+ result= classifier(text)
16
+ return result
17
  io = gr.Interface(fn=text_classification,
18
  inputs= gr.Textbox(lines=2, label="Text", placeholder="Enter title here..."),
19
  outputs=gr.Textbox(lines=2, label="Text Classification Result"),