import gradio as gr #from transformers import AutoModelForSequenceClassification, AutoTokenizer #from transformers import BertTokenizer, BertLMHeadModel # Load pre-trained model and tokenizer #tokenizer = BertTokenizer.from_pretrained('clinicalBERT') #model = BertLMHeadModel.from_pretrained('clinicalBERT') from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("medicalai/ClinicalBERT") model = AutoModel.from_pretrained("medicalai/ClinicalBERT") # 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()