ahmedyoussef1 commited on
Commit
9f48626
·
verified ·
1 Parent(s): 2e9cb77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -8
app.py CHANGED
@@ -9,25 +9,20 @@ tokenizer = AutoTokenizer.from_pretrained("./")
9
  labels = ["Negative", "Positive"]
10
 
11
  def classify_sentiment(text):
12
- ahmedlofti= text
13
  inputs = tokenizer(text, return_tensors="tf", truncation=True, padding=True)
14
  outputs = model(**inputs)
15
  prediction = tf.argmax(outputs.logits, axis=1).numpy()[0]
16
- sentiment = labels[prediction].lower()
17
-
18
- # Return both processed message and classification
19
- return ahmedlofti, sentiment
20
 
21
  with gr.Blocks() as demo:
22
  gr.Markdown("# Fas7ni Feedbacks\nClassify your feedback as positive or negative!")
23
 
24
  with gr.Row():
25
  msg = gr.Textbox(placeholder="Write your comment or feedback here...", label="Enter Feedback")
26
- processed = gr.Textbox(label="Processed Message")
27
- sentiment = gr.Textbox(label="Sentiment")
28
 
29
  submit = gr.Button("Classify")
30
 
31
- submit.click(fn=classify_sentiment, inputs=msg, outputs=[processed, sentiment])
32
 
33
  demo.launch()
 
9
  labels = ["Negative", "Positive"]
10
 
11
  def classify_sentiment(text):
 
12
  inputs = tokenizer(text, return_tensors="tf", truncation=True, padding=True)
13
  outputs = model(**inputs)
14
  prediction = tf.argmax(outputs.logits, axis=1).numpy()[0]
15
+ return labels[prediction].lower()
 
 
 
16
 
17
  with gr.Blocks() as demo:
18
  gr.Markdown("# Fas7ni Feedbacks\nClassify your feedback as positive or negative!")
19
 
20
  with gr.Row():
21
  msg = gr.Textbox(placeholder="Write your comment or feedback here...", label="Enter Feedback")
22
+ output = gr.Textbox(label="Sentiment")
 
23
 
24
  submit = gr.Button("Classify")
25
 
26
+ submit.click(fn=classify_sentiment, inputs=msg, outputs=output)
27
 
28
  demo.launch()