Spaces:
Sleeping
Sleeping
Commit
·
cc65c80
1
Parent(s):
4973fbb
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,9 @@
|
|
| 1 |
-
from annotated_text import annotated_text
|
| 2 |
-
import razdel
|
| 3 |
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
|
| 4 |
import streamlit as st
|
| 5 |
import torch
|
| 6 |
|
| 7 |
-
nltk.download('punkt')
|
| 8 |
-
|
| 9 |
# add the caching decorator and use custom text for spinner
|
| 10 |
@st.cache_resource(show_spinner = "Loading the model...")
|
| 11 |
|
|
@@ -67,7 +65,7 @@ def label_text(text):
|
|
| 67 |
49: 'B-TIME',
|
| 68 |
50: 'I-TIME'}
|
| 69 |
|
| 70 |
-
single_sentence_tokens = [_.text for _ in list(
|
| 71 |
tokenized_input = tokenizer(single_sentence_tokens, is_split_into_words = True, return_tensors = "pt")
|
| 72 |
tokens = tokenized_input.tokens()
|
| 73 |
output = model(**tokenized_input).logits
|
|
|
|
| 1 |
+
from annotated_text import annotated_text
|
| 2 |
+
from razdel import razdel
|
| 3 |
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
|
| 4 |
import streamlit as st
|
| 5 |
import torch
|
| 6 |
|
|
|
|
|
|
|
| 7 |
# add the caching decorator and use custom text for spinner
|
| 8 |
@st.cache_resource(show_spinner = "Loading the model...")
|
| 9 |
|
|
|
|
| 65 |
49: 'B-TIME',
|
| 66 |
50: 'I-TIME'}
|
| 67 |
|
| 68 |
+
single_sentence_tokens = [_.text for _ in list(tokenize(text))]
|
| 69 |
tokenized_input = tokenizer(single_sentence_tokens, is_split_into_words = True, return_tensors = "pt")
|
| 70 |
tokens = tokenized_input.tokens()
|
| 71 |
output = model(**tokenized_input).logits
|