Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| from transformers import pipeline, AutoModelForTokenClassification, AutoTokenizer | |
| # Load model and tokenizer | |
| model_name = "dbmdz/bert-large-cased-finetuned-conll03-english" | |
| model = AutoModelForTokenClassification.from_pretrained(model_name) | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| # Define pipeline for named entity recognition | |
| ner = pipeline('ner', model=model, tokenizer=tokenizer) | |
| # Create a Streamlit app | |
| st.title("Named Entity Recognition with Hugging Face and Streamlit") | |
| text = st.text_input("Enter text:") | |
| if text: | |
| result = ner(text) | |
| for item in result: | |
| st.write(f"{item['entity']} ({item['score']:.2f}): {item['word']}") | |