Spaces:
Sleeping
Sleeping
File size: 855 Bytes
2261644 9c45419 2261644 9c45419 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import gradio as gr
from transformers import AutoTokenizer, AutoModelForMaskedLM, pipeline
# Load BlueBERT model and tokenizer
model_name = "bionlp/bluebert_pubmed_mimic_uncased_L-12_H-768_A-12"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForMaskedLM.from_pretrained(model_name)
# Create a fill-mask pipeline to handle predictions
nlp = pipeline("fill-mask", model=model, tokenizer=tokenizer)
def predict(text):
# Process the text using the model
result = nlp(text)
return result
# Gradio interface to input text and output model predictions
iface = gr.Interface(
fn=predict,
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter a sentence with [MASK]..."),
outputs="json",
title="BlueBERT Testing",
description="Test BlueBERT on biomedical data or general text"
)
iface.launch(share=True) |