Eaz123 commited on
Commit
ff12162
·
verified ·
1 Parent(s): 7fb966a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -8
app.py CHANGED
@@ -5,15 +5,12 @@ import torch
5
  import language_tool_python
6
  import nltk
7
 
8
- # Download required NLTK data
9
  nltk.download('punkt')
10
  nltk.download('averaged_perceptron_tagger')
11
 
12
- # Grammar and paraphrase tools
13
  tool = language_tool_python.LanguageTool('en-US')
14
- parrot = Parrot(model_tag="prithivida/parrot_paraphraser_on_T5", use_gpu=torch.cuda.is_available())
15
 
16
- # Paraphrasing logic
17
  def paraphrase_text(input_text, mode="Standard"):
18
  if not input_text.strip():
19
  return "", ""
@@ -42,7 +39,6 @@ def paraphrase_text(input_text, mode="Standard"):
42
 
43
  return corrected, best
44
 
45
- # Gradio UI
46
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
47
  gr.Markdown("## 🚀 AI Paraphraser — Better Than QuillBot")
48
  gr.Markdown("### Enter your text and select a paraphrasing mode")
@@ -58,7 +54,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
58
  output_paraphrased = gr.Textbox(label="✨ Paraphrased Output", lines=3)
59
 
60
  btn.click(fn=paraphrase_text, inputs=[input_text, mode], outputs=[output_corrected, output_paraphrased])
61
- clear.click(lambda: ("", "", ""), outputs=[input_text, output_corrected, output_paraphrased])
62
 
63
- if __name__ == "__main__":
64
- demo.launch()
 
5
  import language_tool_python
6
  import nltk
7
 
 
8
  nltk.download('punkt')
9
  nltk.download('averaged_perceptron_tagger')
10
 
 
11
  tool = language_tool_python.LanguageTool('en-US')
12
+ parrot = Parrot(model_tag="prithivida/parrot_paraphraser_on_T5", use_gpu=False)
13
 
 
14
  def paraphrase_text(input_text, mode="Standard"):
15
  if not input_text.strip():
16
  return "", ""
 
39
 
40
  return corrected, best
41
 
 
42
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
43
  gr.Markdown("## 🚀 AI Paraphraser — Better Than QuillBot")
44
  gr.Markdown("### Enter your text and select a paraphrasing mode")
 
54
  output_paraphrased = gr.Textbox(label="✨ Paraphrased Output", lines=3)
55
 
56
  btn.click(fn=paraphrase_text, inputs=[input_text, mode], outputs=[output_corrected, output_paraphrased])
57
+ clear.click(lambda: ("", "", ""), None, [input_text, output_corrected, output_paraphrased])
58
 
59
+ demo.launch()