Spaces:
Runtime error
Runtime error
import gradio as gr | |
import json | |
from transformers import AutoTokenizer, AutoModelWithLMHead | |
from transformers import pipeline | |
tokenizer = AutoTokenizer.from_pretrained("gpt2") | |
model = AutoModelWithLMHead.from_pretrained("gpt2-large") | |
generator = pipeline( | |
task="text-generation", | |
model=model, | |
tokenizer=tokenizer, | |
framework="tf" | |
) | |
model = AutoModelWithLMHead.from_pretrained("gpt2") | |
def green(prompt): | |
return generator(prompt, max_length=1000) | |
iface = gr.Interface(fn=green, inputs=gr.inputs.Textbox(lines=2, placeholder="Put prompt here"), outputs=gr.outputs.Textbox(type="str", label="generated text")) | |
iface.launch() |