Kaiyeee commited on
Commit
78dfad9
·
verified ·
1 Parent(s): d371554

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -40,7 +40,9 @@ def predict(texts, threshold=0.3):
40
  def predict_bulk(texts_str, threshold=0.3):
41
  texts = [line.strip() for line in texts_str.split("\n") if line.strip()]
42
  results = predict(texts, threshold)
43
- return "\n".join(f"{t}: {r}" for t, r in zip(texts, results))
 
 
44
 
45
  # Process CSV file upload
46
  def predict_file(file_obj, threshold=0.3):
@@ -55,13 +57,13 @@ def predict_file(file_obj, threshold=0.3):
55
  return out_path
56
 
57
  with gr.Blocks() as demo:
58
- gr.Markdown("# 👀 GoEmotions Multi-Label Demo")
59
 
60
  thr = gr.Slider(0.1, 0.9, 0.3, label="Threshold")
61
 
62
  with gr.Tab("Paste Text (one per line)"):
63
  inp = gr.Textbox(label="Enter texts (one per line)", lines=10, placeholder="Enter sentences here")
64
- out = gr.Textbox(label="Predicted emotions")
65
  btn = gr.Button("Analyze")
66
  btn.click(fn=predict_bulk, inputs=[inp, thr], outputs=out)
67
 
 
40
  def predict_bulk(texts_str, threshold=0.3):
41
  texts = [line.strip() for line in texts_str.split("\n") if line.strip()]
42
  results = predict(texts, threshold)
43
+ # Format with bold emotions
44
+ formatted = "\n".join(f"{t}: " + ", ".join(f"**{e}**" for e in r.split(", ")) for t, r in zip(texts, results))
45
+ return formatted
46
 
47
  # Process CSV file upload
48
  def predict_file(file_obj, threshold=0.3):
 
57
  return out_path
58
 
59
  with gr.Blocks() as demo:
60
+ gr.Markdown("# 🦄 GoEmotions Multi-Label Demo")
61
 
62
  thr = gr.Slider(0.1, 0.9, 0.3, label="Threshold")
63
 
64
  with gr.Tab("Paste Text (one per line)"):
65
  inp = gr.Textbox(label="Enter texts (one per line)", lines=10, placeholder="Enter sentences here")
66
+ out = gr.Markdown(label="Predicted emotions")
67
  btn = gr.Button("Analyze")
68
  btn.click(fn=predict_bulk, inputs=[inp, thr], outputs=out)
69