Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,44 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
pipe = pipeline(model="RuudVelo/dutch_news_classifier_bert_finetuned")
|
| 5 |
-
text = st.text_area('Please type/copy/paste the Dutch article')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
| 9 |
|
| 10 |
if text:
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
#pipe = pipeline(model="RuudVelo/dutch_news_classifier_bert_finetuned")
|
| 5 |
+
#text = st.text_area('Please type/copy/paste the Dutch article')
|
| 6 |
+
|
| 7 |
+
#labels = ['Binnenland' 'Buitenland' 'Cultuur & Media' 'Economie' 'Koningshuis'
|
| 8 |
+
# 'Opmerkelijk' 'Politiek' 'Regionaal nieuws' 'Tech']
|
| 9 |
+
|
| 10 |
+
#if text:
|
| 11 |
+
# out = pipe(text)
|
| 12 |
+
# st.json(out)
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
# load tokenizer and model, create trainer
|
| 16 |
+
#model_name = "RuudVelo/dutch_news_classifier_bert_finetuned"
|
| 17 |
+
#tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 18 |
+
#model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 19 |
+
#trainer = Trainer(model=model)
|
| 20 |
+
#print(filename, type(filename))
|
| 21 |
+
#print(filename.name)
|
| 22 |
+
|
| 23 |
+
from transformers import BertForSequenceClassification, BertTokenizer
|
| 24 |
+
|
| 25 |
+
model = BertForSequenceClassification.from_pretrained("RuudVelo/dutch_news_classifier_bert_finetuned")
|
| 26 |
+
#from transformers import BertTokenizer
|
| 27 |
|
| 28 |
+
tokenizer = BertTokenizer.from_pretrained("RuudVelo/dutch_news_classifier_bert_finetuned")
|
| 29 |
+
|
| 30 |
+
#text = ["this is one sentence", "this is another sentence"]
|
| 31 |
+
text = st.text_area('Please type/copy/paste the Dutch article')
|
| 32 |
|
| 33 |
if text:
|
| 34 |
+
encoding = tokenizer(text, return_tensors="pt")
|
| 35 |
+
outputs = model(**encoding)
|
| 36 |
+
predictions = outputs.logits.argmax(-1)
|
| 37 |
+
#out = pipe(text)
|
| 38 |
+
st.json(predictions)
|
| 39 |
+
|
| 40 |
+
#encoding = tokenizer(text, return_tensors="pt")
|
| 41 |
+
|
| 42 |
+
# forward pass
|
| 43 |
+
#outputs = model(**encoding)
|
| 44 |
+
#predictions = outputs.logits.argmax(-1)
|