Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import AutoModelForSequenceClassification, AutoTokenizer | |
from transformers import BertTokenizer, BertLMHeadModel | |
# Load pre-trained model and tokenizer | |
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased') | |
model = BertLMHeadModel.from_pretrained('bert-base-uncased') | |
# Define a function to generate text using the model | |
def generate_text(input_text): | |
input_ids = tokenizer.encode(input_text, return_tensors='pt') | |
output = model.generate(input_ids) | |
return tokenizer.decode(output[0], skip_special_tokens=True) | |
interface = gr.Interface(fn=generate_text, inputs="text", outputs="text") | |
interface.launch() | |