Spaces:
Sleeping
Sleeping
feat(main): split into files
Browse files
shad_mlops_transformers/main.py
CHANGED
@@ -1,8 +1,15 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
st.markdown("### Hello there")
|
4 |
st.markdown("<img width=200px src='https://rozetked.me/images/uploads/dwoilp3BVjlE.jpg'>", unsafe_allow_html=True)
|
5 |
|
6 |
text = st.text_area("TEXT HERE")
|
7 |
|
8 |
-
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
from transformers import AutoModelForTokenClassification, AutoTokenizer, pipeline
|
3 |
+
|
4 |
+
tokenizer = AutoTokenizer.from_pretrained("Davlan/distilbert-base-multilingual-cased-ner-hrl")
|
5 |
+
model = AutoModelForTokenClassification.from_pretrained("Davlan/distilbert-base-multilingual-cased-ner-hrl")
|
6 |
+
nlp = pipeline("ner", model=model, tokenizer=tokenizer)
|
7 |
|
8 |
st.markdown("### Hello there")
|
9 |
st.markdown("<img width=200px src='https://rozetked.me/images/uploads/dwoilp3BVjlE.jpg'>", unsafe_allow_html=True)
|
10 |
|
11 |
text = st.text_area("TEXT HERE")
|
12 |
|
13 |
+
raw_predictions = nlp("is this real?")
|
14 |
+
|
15 |
+
st.markdown(f"{raw_predictions}")
|
shad_mlops_transformers/model.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoModelForTokenClassification, AutoTokenizer, pipeline
|
2 |
+
|
3 |
+
tokenizer = AutoTokenizer.from_pretrained("Davlan/distilbert-base-multilingual-cased-ner-hrl")
|
4 |
+
model = AutoModelForTokenClassification.from_pretrained("Davlan/distilbert-base-multilingual-cased-ner-hrl")
|
5 |
+
nlp = pipeline("ner", model=model, tokenizer=tokenizer)
|
6 |
+
example = "Nader Jokhadar had given Syria the lead with a well-struck header in the seventh minute."
|
7 |
+
ner_results = nlp(example)
|
8 |
+
print(ner_results)
|
shad_mlops_transformers/ui.py
ADDED
File without changes
|