Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,6 @@
|
|
1 |
-
import
|
2 |
-
from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
3 |
|
4 |
-
model_name = "
|
5 |
tokenizer = GPT2Tokenizer.from_pretrained(model_name)
|
6 |
-
model =
|
7 |
|
8 |
-
def generate_text(prompt):
|
9 |
-
inputs = tokenizer.encode(prompt, return_tensors="pt")
|
10 |
-
outputs = model.generate(inputs, max_length=100, num_return_sequences=1)
|
11 |
-
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
12 |
-
|
13 |
-
interface = gr.Interface(fn=generate_text, inputs="text", outputs="text")
|
14 |
-
interface.launch()
|
|
|
1 |
+
from transformers import TFGPT2LMHeadModel, GPT2Tokenizer
|
|
|
2 |
|
3 |
+
model_name = "gpt2"
|
4 |
tokenizer = GPT2Tokenizer.from_pretrained(model_name)
|
5 |
+
model = TFGPT2LMHeadModel.from_pretrained(model_name)
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|