arputtick commited on
Commit
9ae6a25
·
1 Parent(s): 5ac6617

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -1,15 +1,25 @@
1
  from transformers import pipeline, set_seed
2
  import gradio as gr
 
 
 
3
 
4
  classifier = pipeline('text-generation', model='arputtick/GPT_Neo_1.3B_eco_feminist_2')
5
  set_seed(42)
6
 
7
  def generate_text(text, gen_length):
8
  gen_text = classifier(text, max_length=gen_length)[0]['generated_text']
9
- return gen_text
 
 
 
 
 
 
 
10
 
11
  Instructuction = "Browse the internet to download any unique image"
12
- title="Eco-Feminists Text Generation"
13
  description = "Start writing a peice of text in the input box\
14
  and see how well the text generation language model\
15
  is able to generate new text that uniquely completes your sentences."
 
1
  from transformers import pipeline, set_seed
2
  import gradio as gr
3
+ import nltk
4
+
5
+ nltk.download('punkt')
6
 
7
  classifier = pipeline('text-generation', model='arputtick/GPT_Neo_1.3B_eco_feminist_2')
8
  set_seed(42)
9
 
10
  def generate_text(text, gen_length):
11
  gen_text = classifier(text, max_length=gen_length)[0]['generated_text']
12
+ sentences = nltk.sent_tokenize(gen_text)
13
+
14
+ if sentences[-1][-1] == ".":
15
+ output = sentences
16
+
17
+ else:
18
+ output = sentences[:-1]
19
+ return output
20
 
21
  Instructuction = "Browse the internet to download any unique image"
22
+ title="Eco-Feminist Text Generation"
23
  description = "Start writing a peice of text in the input box\
24
  and see how well the text generation language model\
25
  is able to generate new text that uniquely completes your sentences."