Wootang01 commited on
Commit
a27137b
·
1 Parent(s): 8de8551

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -17
app.py CHANGED
@@ -1,20 +1,13 @@
1
  import gradio as gr
2
- from aitextgen import aitextgen
3
- from transformers import Pipeline
4
 
5
- ai = aitextgen(model="EleutherAI/gpt-neo-1.3B")
6
 
7
- def ai_text(inp):
8
- generated_text = ai.generate_one(max_length=100, prompt = inp, no_repeat_ngram_size=3)
9
- print(type(generated_text))
10
- return generated_text
11
-
12
- examples = [
13
- ["Artificial intelligence will"],
14
- ["Probably everyone has heard of the 20 year-old singer named Zoe Kwan."],
15
- ["Mars, Joyce and Venus had their first day at Blazing Inventions Academy in North Point, Hong Kong. The following day, while Mars, Joyce and Venus are eating breakfast in the Academy’s hall, a green gas spreads from North Point throughout the world."]
16
- ]
17
-
18
- output_text = gr.outputs.Textbox()
19
- gr.Interface(ai_text,"textbox", output_text, title="Text Generator GPT-Neo-1.3B",
20
- description="Copy or type text. Submit and the machine will generate text.", examples=examples).launch(share=False)
 
1
  import gradio as gr
 
 
2
 
3
+ api = gr.Interface.load("huggingface/EleutherAI/gpt-neo-1.3B")
4
 
5
+ def ai_text(text):
6
+ return text [:-50] + api(text[-50:])
7
+
8
+ with gr.Blocks as demo():
9
+ textbox = gr.Textbox(placeholder="Input text", lines=5)
10
+ btn = gr.Button("Submit")
11
+ btn.click(ai_text, textbox, textbox)
12
+
13
+ demo.launch()