Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,14 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import AutoTokenizer, AutoModelForTokenClassification
|
3 |
from transformers import pipeline
|
|
|
|
|
|
|
|
|
4 |
|
5 |
# Load the model and tokenizer
|
6 |
-
|
7 |
-
|
8 |
-
model = AutoModelForTokenClassification.from_pretrained(model_name)
|
9 |
nlp = pipeline("ner", model=model, tokenizer=tokenizer, aggregation_strategy="simple")
|
10 |
|
11 |
st.title("Token Classification with Hugging Face")
|
@@ -17,7 +20,7 @@ if st.button("Classify Text"):
|
|
17 |
if user_input:
|
18 |
# Token classification
|
19 |
results = nlp(user_input)
|
20 |
-
|
21 |
# Display results
|
22 |
st.write("### Token Classification Results")
|
23 |
for entity in results:
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import AutoTokenizer, AutoModelForTokenClassification
|
3 |
from transformers import pipeline
|
4 |
+
import os
|
5 |
+
|
6 |
+
# Define the path where model and tokenizer files are located
|
7 |
+
model_directory = "AdilHayat173/token_classification"
|
8 |
|
9 |
# Load the model and tokenizer
|
10 |
+
tokenizer = AutoTokenizer.from_pretrained(model_directory)
|
11 |
+
model = AutoModelForTokenClassification.from_pretrained(model_directory)
|
|
|
12 |
nlp = pipeline("ner", model=model, tokenizer=tokenizer, aggregation_strategy="simple")
|
13 |
|
14 |
st.title("Token Classification with Hugging Face")
|
|
|
20 |
if user_input:
|
21 |
# Token classification
|
22 |
results = nlp(user_input)
|
23 |
+
|
24 |
# Display results
|
25 |
st.write("### Token Classification Results")
|
26 |
for entity in results:
|