ahmedyoussef1 commited on
Commit
46bb5a0
·
verified ·
1 Parent(s): 9f48626

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -12,17 +12,21 @@ 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()
 
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
+ sentiment = labels[prediction].lower()
16
+
17
+ # Return both processed message and classification
18
+ return text, sentiment
19
 
20
  with gr.Blocks() as demo:
21
  gr.Markdown("# Fas7ni Feedbacks\nClassify your feedback as positive or negative!")
22
 
23
  with gr.Row():
24
  msg = gr.Textbox(placeholder="Write your comment or feedback here...", label="Enter Feedback")
25
+ processed = gr.Textbox(label="Processed Message")
26
+ sentiment = gr.Textbox(label="Sentiment")
27
 
28
  submit = gr.Button("Classify")
29
 
30
+ submit.click(fn=classify_sentiment, inputs=msg, outputs=[processed, sentiment])
31
 
32
  demo.launch()