aryn25 commited on
Commit
53dac87
·
verified ·
1 Parent(s): edb4b31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -2,14 +2,12 @@ import gradio as gr
2
  from transformers import pipeline
3
 
4
  # Load zero-shot classifier for bias detection using Facebook's BART MNLI.
5
- # This model will classify the input text into "biased" or "neutral".
6
  classifier = pipeline(
7
  "zero-shot-classification",
8
  model="facebook/bart-large-mnli"
9
  )
10
 
11
  # Load FLAN-T5 for rewriting text.
12
- # This model will generate a neutral version of biased text.
13
  rewriter = pipeline(
14
  "text2text-generation",
15
  model="google/flan-t5-base",
@@ -38,7 +36,7 @@ def process_text(text):
38
  # Return results in a dictionary.
39
  return {
40
  "Detected Bias": detected_bias,
41
- "Confidence": confidence,
42
  "Rewritten Text": rewritten_text
43
  }
44
 
@@ -56,8 +54,10 @@ with gr.Blocks() as demo:
56
  placeholder="Type a story or sentence here...",
57
  lines=5
58
  )
 
 
59
  result_output = gr.JSON(label="Output")
60
 
61
- text_input.submit(process_text, inputs=[text_input], outputs=[result_output])
62
 
63
  demo.launch()
 
2
  from transformers import pipeline
3
 
4
  # Load zero-shot classifier for bias detection using Facebook's BART MNLI.
 
5
  classifier = pipeline(
6
  "zero-shot-classification",
7
  model="facebook/bart-large-mnli"
8
  )
9
 
10
  # Load FLAN-T5 for rewriting text.
 
11
  rewriter = pipeline(
12
  "text2text-generation",
13
  model="google/flan-t5-base",
 
36
  # Return results in a dictionary.
37
  return {
38
  "Detected Bias": detected_bias,
39
+ "Confidence": round(confidence, 2),
40
  "Rewritten Text": rewritten_text
41
  }
42
 
 
54
  placeholder="Type a story or sentence here...",
55
  lines=5
56
  )
57
+
58
+ submit_btn = gr.Button("Submit")
59
  result_output = gr.JSON(label="Output")
60
 
61
+ submit_btn.click(fn=process_text, inputs=[text_input], outputs=[result_output])
62
 
63
  demo.launch()