Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,12 +2,6 @@ import torch
|
|
2 |
import streamlit as st
|
3 |
from transformers import pipeline, AutoTokenizer,AutoModelForTokenClassification
|
4 |
|
5 |
-
tokenizer=AutoTokenizer.from_pretrained("KoichiYasuoka/bert-base-japanese-upos")
|
6 |
-
model=AutoModelForTokenClassification.from_pretrained("KoichiYasuoka/bert-base-japanese-upos")
|
7 |
-
s="国境の長いトンネルを抜けると雪国であった。"
|
8 |
-
p=[model.config.id2label[q] for q in torch.argmax(model(tokenizer.encode(s,return_tensors="pt"))["logits"],dim=2)[0].tolist()[1:-1]]
|
9 |
-
print(list(zip(s,p)))
|
10 |
-
|
11 |
classifier = pipeline("token-classification", model="KoichiYasuoka/bert-base-japanese-upos")
|
12 |
def main():
|
13 |
st.title("POS-tagging for Japanese texts")
|
@@ -21,7 +15,6 @@ def main():
|
|
21 |
if clicked:
|
22 |
results = classifier([text])
|
23 |
st.json(results)
|
24 |
-
st.success(p)
|
25 |
|
26 |
if __name__ == "__main__":
|
27 |
main()
|
|
|
2 |
import streamlit as st
|
3 |
from transformers import pipeline, AutoTokenizer,AutoModelForTokenClassification
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
classifier = pipeline("token-classification", model="KoichiYasuoka/bert-base-japanese-upos")
|
6 |
def main():
|
7 |
st.title("POS-tagging for Japanese texts")
|
|
|
15 |
if clicked:
|
16 |
results = classifier([text])
|
17 |
st.json(results)
|
|
|
18 |
|
19 |
if __name__ == "__main__":
|
20 |
main()
|