Spaces:
Running
Running
azaninello
commited on
Commit
•
3304da1
1
Parent(s):
4039b68
Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,18 @@
|
|
1 |
import gradio as gr
|
2 |
import transformers
|
3 |
-
from transformers import AutoModelWithLMHead, AutoTokenizer, pipeline
|
4 |
from transformers import GPT2Tokenizer, GPT2Model
|
5 |
|
6 |
-
model = GPT2Model.from_pretrained('gpt2')
|
7 |
-
tokenizer = GPT2Tokenizer.from_pretrained(
|
8 |
-
'gpt2',
|
9 |
-
)
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
#top_p=0.95,
|
17 |
-
)
|
18 |
|
19 |
def generator(start_your_text = ''):
|
20 |
-
|
21 |
-
return
|
22 |
|
23 |
iface = gr.Interface(fn=generator, inputs="text", outputs="text")
|
24 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import transformers
|
3 |
+
from transformers import AutoModelForCausalLM, AutoModelWithLMHead, AutoTokenizer, pipeline
|
4 |
from transformers import GPT2Tokenizer, GPT2Model
|
5 |
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
general_model = AutoModelForCausalLM.from_pretrained('gpt2')
|
8 |
+
general_generator = pipeline("text-generation", model=general_model, tokenizer="gpt2")
|
9 |
+
general_result = general_generator("Today is ", max_length=120)
|
10 |
+
general_result[0]["generated_text"]
|
11 |
+
|
|
|
|
|
12 |
|
13 |
def generator(start_your_text = ''):
|
14 |
+
result = general_generator(start_your_text)
|
15 |
+
return result[0]["generated_text"]
|
16 |
|
17 |
iface = gr.Interface(fn=generator, inputs="text", outputs="text")
|
18 |
iface.launch()
|