creaoy commited on
Commit
27794a9
1 Parent(s): 0385b20

Add application file

Browse files
Files changed (2) hide show
  1. app.py +32 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from aitextgen import aitextgen
2
+ import gradio as gr
3
+ import os
4
+ from transformers import pipeline
5
+ from gradio import inputs
6
+ from gradio.inputs import Textbox
7
+ from gradio import outputs
8
+
9
+
10
+ ai=aitextgen(model='EleutherAI/gpt-neo-2.7B',to_gpu=False) # EleutherAI/gpt-neo-2.7B EleutherAI/gpt-neo-1.3B
11
+ # ai=aitextgen(model='EleutherAI/gpt-neo-1.3B',to_gpu=False)
12
+
13
+ def ai_text(Input):
14
+ generated_text = ai.generate_one(max_length = 1000, prompt = Input, no_repeat_ngram_size = 3) #repetition_penalty = 1.9)
15
+ #print(type(generated_text))
16
+ return generated_text
17
+
18
+
19
+ title_ = "AI Long Content Generation"
20
+ description_ = "Converts short sentences into 1000 words"
21
+ output_text = gr.outputs.Textbox()
22
+ iface=gr.Interface(ai_text,"textbox", output_text, title=title_,description=description_)#.launch()
23
+ iface.launch()
24
+
25
+
26
+
27
+ #HF_TOKEN = os.environ.get("HF_TOKEN")
28
+ #generator2 = gr.Interface.load("huggingface/EleutherAI/gpt-neo-2.7B", api_key=HF_TOKEN) # add api_key=HF_TOKEN to get over the quota error
29
+ #generator3 = gr.Interface.load("huggingface/EleutherAI/gpt-j-6B", api_key=HF_TOKEN)
30
+ #generator1 = gr.Interface.load("huggingface/gpt2-large", api_key=HF_TOKEN)
31
+ #gr.Parallel(generator1, generator2, generator3, inputs=gr.inputs.Textbox(lines=5, label="Enter a sentence to get another sentence."),
32
+ # title=title, examples=examples).launch(share=False)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ aitextgen
2
+ gradio