Farhan1572 commited on
Commit
4b19bc2
β€’
1 Parent(s): 4b6dc55

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -24
app.py CHANGED
@@ -1,12 +1,12 @@
1
  import gradio as gr
2
- # import torch
3
- # from transformers import PegasusForConditionalGeneration, PegasusTokenizer
4
- # from sentence_splitter import SentenceSplitter, split_text_into_sentences
5
 
6
- # model_name = 'tuner007/pegasus_paraphrase'
7
- # torch_device = 'cuda' if torch.cuda.is_available() else 'cpu'
8
- # tokenizer = PegasusTokenizer.from_pretrained(model_name)
9
- # model = PegasusForConditionalGeneration.from_pretrained(model_name).to(torch_device)
10
 
11
 
12
  def get_response(input_text, num_return_sequences):
@@ -35,23 +35,7 @@ def get_response_from_text(
35
 
36
 
37
  def greet(context):
38
- # paraphrased_text = []
39
- paragraphs = context.split("\n")
40
- # for paragraph in paragraphs:
41
-
42
- # try:
43
-
44
- # paraphrased_paragraph = get_response_from_text(paragraph)
45
-
46
- # paraphrased_text.append(paraphrased_paragraph)
47
-
48
- # except:
49
- # pass
50
-
51
- # # Join the text list into a single text with newlines
52
- # output_text = "\n".join(paraphrased_text)
53
-
54
- return paragraphs
55
 
56
 
57
  iface = gr.Interface(fn=greet, inputs="text", outputs="text", title="Developed by Farhan Siddiqui")
 
1
  import gradio as gr
2
+ import torch
3
+ from transformers import PegasusForConditionalGeneration, PegasusTokenizer
4
+ from sentence_splitter import SentenceSplitter, split_text_into_sentences
5
 
6
+ model_name = 'tuner007/pegasus_paraphrase'
7
+ torch_device = 'cuda' if torch.cuda.is_available() else 'cpu'
8
+ tokenizer = PegasusTokenizer.from_pretrained(model_name)
9
+ model = PegasusForConditionalGeneration.from_pretrained(model_name).to(torch_device)
10
 
11
 
12
  def get_response(input_text, num_return_sequences):
 
35
 
36
 
37
  def greet(context):
38
+ return get_response_from_text(context)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
 
41
  iface = gr.Interface(fn=greet, inputs="text", outputs="text", title="Developed by Farhan Siddiqui")