Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,7 @@
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import pipeline,
|
3 |
from datasets import load_dataset
|
4 |
import pandas as pd
|
5 |
|
@@ -43,15 +45,16 @@ elif input_method == "Yeni Metin Yaz veya Yapıştır":
|
|
43 |
# Model ve tokenizer'ı yükleme
|
44 |
@st.cache_resource
|
45 |
def set_model(model_checkpoint):
|
46 |
-
|
|
|
47 |
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
|
48 |
|
49 |
# Named Entity Recognition (NER) için model
|
50 |
-
ner_model =
|
51 |
ner_tokenizer = AutoTokenizer.from_pretrained('dbmdz/bert-large-cased-finetuned-conll03-english')
|
52 |
|
53 |
return {
|
54 |
-
'sentiment_pipeline': pipeline('sentiment-analysis', model=
|
55 |
'ner_pipeline': pipeline('ner', model=ner_model, tokenizer=ner_tokenizer)
|
56 |
}
|
57 |
|
|
|
1 |
+
!pip install torch
|
2 |
+
|
3 |
import streamlit as st
|
4 |
+
from transformers import pipeline, AutoModelForSequenceClassification, AutoTokenizer, AutoModelForTokenClassification
|
5 |
from datasets import load_dataset
|
6 |
import pandas as pd
|
7 |
|
|
|
45 |
# Model ve tokenizer'ı yükleme
|
46 |
@st.cache_resource
|
47 |
def set_model(model_checkpoint):
|
48 |
+
# PyTorch tabanlı modelleri kullan
|
49 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_checkpoint)
|
50 |
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
|
51 |
|
52 |
# Named Entity Recognition (NER) için model
|
53 |
+
ner_model = AutoModelForTokenClassification.from_pretrained('dbmdz/bert-large-cased-finetuned-conll03-english')
|
54 |
ner_tokenizer = AutoTokenizer.from_pretrained('dbmdz/bert-large-cased-finetuned-conll03-english')
|
55 |
|
56 |
return {
|
57 |
+
'sentiment_pipeline': pipeline('sentiment-analysis', model=model, tokenizer=tokenizer),
|
58 |
'ner_pipeline': pipeline('ner', model=ner_model, tokenizer=ner_tokenizer)
|
59 |
}
|
60 |
|