NoaiGPT commited on
Commit
b26218c
1 Parent(s): 6a956f7
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -570,6 +570,9 @@ def classify_text(text):
570
  main_score = probabilities[0][predicted_class].item()
571
  return main_label, main_score
572
 
 
 
 
573
  @spaces.GPU
574
  def generate_paraphrases(text, setting, output_format):
575
  sentences = splitter.split(text)
@@ -689,20 +692,21 @@ def generate_paraphrases(text, setting, output_format):
689
  else:
690
  return json.dumps(json_output, indent=2), "\n\n".join([v[0] for v in human_versions])
691
 
 
 
 
 
692
  # Define the Gradio interface
693
  iface = gr.Interface(
694
- fn=generate_paraphrases,
695
  inputs=[
696
- gr.Textbox(lines=5, label="Input Text"),
697
- gr.Slider(minimum=1, maximum=5, step=1, label="Readability to Human-like Setting"),
698
- gr.Radio(["text", "json"], label="Output Format")
699
  ],
700
  outputs=[
701
- gr.Textbox(lines=20, label="Detailed Paraphrases and Classifications"),
702
- gr.Textbox(lines=10, label="Human-like or Less Confident Machine-generated Paraphrases")
703
  ],
704
- title="Advanced Diverse Paraphraser with Human-like Filter",
705
- description="Enter a text, select a setting from readable to human-like, and choose the output format to generate diverse paraphrased versions. Combined versions are classified, and those detected as human-produced or less confidently machine-generated are presented in the final output."
706
  )
707
 
708
  # Launch the interface
 
570
  main_score = probabilities[0][predicted_class].item()
571
  return main_label, main_score
572
 
573
+ def clean_text(text):
574
+ return text.replace("paraphrasedoutput: ", "")
575
+
576
  @spaces.GPU
577
  def generate_paraphrases(text, setting, output_format):
578
  sentences = splitter.split(text)
 
692
  else:
693
  return json.dumps(json_output, indent=2), "\n\n".join([v[0] for v in human_versions])
694
 
695
+ def clean_paraphrased_output(text):
696
+ cleaned_text = clean_text(text)
697
+ return cleaned_text
698
+
699
  # Define the Gradio interface
700
  iface = gr.Interface(
701
+ fn=clean_paraphrased_output,
702
  inputs=[
703
+ gr.Textbox(lines=5, label="Input Text")
 
 
704
  ],
705
  outputs=[
706
+ gr.Textbox(lines=20, label="Cleaned Text")
 
707
  ],
708
+ title="Clean Paraphrased Output",
709
+ description="Enter a text with 'paraphrasedoutput:' prefix and get the cleaned text."
710
  )
711
 
712
  # Launch the interface