ihsan66 commited on
Commit
5311840
1 Parent(s): bf24933

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -1,5 +1,7 @@
 
 
1
  import streamlit as st
2
- from transformers import pipeline, TFAutoModelForSequenceClassification, AutoTokenizer, TFAutoModelForTokenClassification
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
- sentiment_model = TFAutoModelForSequenceClassification.from_pretrained(model_checkpoint, from_tf=True)
 
47
  tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
48
 
49
  # Named Entity Recognition (NER) için model
50
- ner_model = TFAutoModelForTokenClassification.from_pretrained('dbmdz/bert-large-cased-finetuned-conll03-english', from_tf=True)
51
  ner_tokenizer = AutoTokenizer.from_pretrained('dbmdz/bert-large-cased-finetuned-conll03-english')
52
 
53
  return {
54
- 'sentiment_pipeline': pipeline('sentiment-analysis', model=sentiment_model, tokenizer=tokenizer),
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