Spaces:
Sleeping
Sleeping
Upload 9 files
Browse files- app.py +35 -0
- data.json +0 -0
- requirements.txt +10 -0
- your_model_directory/config.json +0 -0
- your_model_directory/model.safetensors +3 -0
- your_model_directory/special_tokens_map.json +7 -0
- your_model_directory/tokenizer.json +0 -0
- your_model_directory/tokenizer_config.json +55 -0
- your_model_directory/vocab.txt +0 -0
app.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
# Define label dictionary (adjust based on your data and model)
|
| 6 |
+
label_dict = {
|
| 7 |
+
0: "Yanlış Anlama Değil",
|
| 8 |
+
1: "Yanlış Anlama",
|
| 9 |
+
# ... other labels (add more if needed)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
# Load model and tokenizer
|
| 13 |
+
model_name = "your_model_directory"
|
| 14 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 15 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 16 |
+
|
| 17 |
+
# Select device (GPU if available)
|
| 18 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 19 |
+
model.to(device)
|
| 20 |
+
|
| 21 |
+
# User input
|
| 22 |
+
text = st.text_input("Yanlış anlama olup olmadığını kontrol etmek istediğiniz metni girin:")
|
| 23 |
+
|
| 24 |
+
# Prediction (if text is provided)
|
| 25 |
+
if text:
|
| 26 |
+
inputs = tokenizer(text, return_tensors='pt').to(device)
|
| 27 |
+
outputs = model(**inputs)
|
| 28 |
+
logits = outputs.logits
|
| 29 |
+
predicted_class_id = torch.argmax(logits, dim=1).item()
|
| 30 |
+
|
| 31 |
+
# Handle predicted class ID
|
| 32 |
+
if predicted_class_id in label_dict:
|
| 33 |
+
st.write("Tahmin edilen sonuç:", label_dict[predicted_class_id])
|
| 34 |
+
else:
|
| 35 |
+
st.write("Tahmin edilen sonuç:", "Model tarafından bilinmeyen bir yanlış anlama türü")
|
data.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
requirements.txt
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
tensorflow
|
| 3 |
+
opencv-python
|
| 4 |
+
scikit-learn
|
| 5 |
+
torch
|
| 6 |
+
torchvision
|
| 7 |
+
matplotlib
|
| 8 |
+
transformers
|
| 9 |
+
sentencepiece
|
| 10 |
+
plotly
|
your_model_directory/config.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
your_model_directory/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2d4f7ddd579efbb0cf5f8164aa985eadc0db314372e12c705ab50af3a35fb7dc
|
| 3 |
+
size 445910108
|
your_model_directory/special_tokens_map.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cls_token": "[CLS]",
|
| 3 |
+
"mask_token": "[MASK]",
|
| 4 |
+
"pad_token": "[PAD]",
|
| 5 |
+
"sep_token": "[SEP]",
|
| 6 |
+
"unk_token": "[UNK]"
|
| 7 |
+
}
|
your_model_directory/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
your_model_directory/tokenizer_config.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "[PAD]",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"100": {
|
| 12 |
+
"content": "[UNK]",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"101": {
|
| 20 |
+
"content": "[CLS]",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"102": {
|
| 28 |
+
"content": "[SEP]",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"103": {
|
| 36 |
+
"content": "[MASK]",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"clean_up_tokenization_spaces": false,
|
| 45 |
+
"cls_token": "[CLS]",
|
| 46 |
+
"do_lower_case": true,
|
| 47 |
+
"mask_token": "[MASK]",
|
| 48 |
+
"model_max_length": 512,
|
| 49 |
+
"pad_token": "[PAD]",
|
| 50 |
+
"sep_token": "[SEP]",
|
| 51 |
+
"strip_accents": null,
|
| 52 |
+
"tokenize_chinese_chars": true,
|
| 53 |
+
"tokenizer_class": "BertTokenizer",
|
| 54 |
+
"unk_token": "[UNK]"
|
| 55 |
+
}
|
your_model_directory/vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|