Update app.py
Browse files
app.py
CHANGED
@@ -5,19 +5,23 @@ os.system("pip install tensorflow")
|
|
5 |
os.system("pip install torch")
|
6 |
import gradio as gr
|
7 |
|
8 |
-
import tensorflow as tf
|
9 |
-
from transformers import GPT2LMHeadModel, GPT2Tokenizer, set_seed
|
10 |
-
tokenizer = GPT2Tokenizer.from_pretrained("gpt2-large")
|
11 |
-
model = GPT2LMHeadModel.from_pretrained("gpt2-large", pad_token_id=tokenizer.eos_token_id)
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
return out
|
22 |
|
23 |
|
@@ -25,7 +29,7 @@ def generate(prompt,textCount=200):
|
|
25 |
demo = gr.Interface(
|
26 |
fn=generate,
|
27 |
inputs=[gr.Textbox(lines=8, placeholder="Paragraph Here..."),"number"],
|
28 |
-
outputs="text",title="Text generation app with
|
29 |
description="This is a text generation app, it can prove useful when you want to generate texts. All you need to do is copy and paste a short prompt. The potential of this app is limitless especially for writers, you are only limited by your prompt engineering skills",
|
30 |
examples=[
|
31 |
["During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in"
|
|
|
5 |
os.system("pip install torch")
|
6 |
import gradio as gr
|
7 |
|
8 |
+
#import tensorflow as tf
|
9 |
+
#from transformers import GPT2LMHeadModel, GPT2Tokenizer, set_seed
|
10 |
+
#tokenizer = GPT2Tokenizer.from_pretrained("gpt2-large")
|
11 |
+
#model = GPT2LMHeadModel.from_pretrained("gpt2-large", pad_token_id=tokenizer.eos_token_id)
|
12 |
+
|
13 |
+
|
14 |
+
from transformers import pipeline
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
def generate(prompt,textCount=40):
|
19 |
+
if textCount == None or textCount < 40:
|
20 |
+
textCount = 40
|
21 |
+
generator = pipeline('text-generation', model="facebook/opt-1.3b", do_sample=True, num_return_sequences=3, max_length=textCount)
|
22 |
+
out = generator(prompt)
|
23 |
+
|
24 |
+
|
25 |
return out
|
26 |
|
27 |
|
|
|
29 |
demo = gr.Interface(
|
30 |
fn=generate,
|
31 |
inputs=[gr.Textbox(lines=8, placeholder="Paragraph Here..."),"number"],
|
32 |
+
outputs="text",title="Text generation app with Facebook opt",
|
33 |
description="This is a text generation app, it can prove useful when you want to generate texts. All you need to do is copy and paste a short prompt. The potential of this app is limitless especially for writers, you are only limited by your prompt engineering skills",
|
34 |
examples=[
|
35 |
["During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in"
|